php - 用户注册后 Laravel 5.4 Passport 重定向

标签 php laravel redirect oauth laravel-passport

当实现 Laravel 5.4 Passport 并调用 /oauth/authorize 时,如果没有找到 session ,Auth 中间件将重定向到 /login 并使用必要的参数。登录后,重定向返回到 /oauth/authorize 路由以完成该过程。

这按预期工作。

但是,如果我们需要用户在授权之前注册,那么在成功注册后将不再重定向到预期的 /oauth/authorize uri。

我已经详细介绍了中间件和身份验证框架代码。仅提出 Redirect::intended(),它基于 url.intended 的 session key ,但即使在显示 时也是 null/登录

有什么线索可以让我在注册时重定向回 /oauth/authorize 页面吗?

最佳答案

在RegisterController中添加这段代码 您需要使用 redirect()->intended($this->redirectPath()) 而不是 redirect($this->redirectPath())

来重定向它
public function register(Request $request)
    {
        $this->validator($request->all())->validate();

        event(new Registered($user = $this->create($request->all())));

        $this->guard()->login($user);

        if ($response = $this->registered($request, $user)) {
            return $response;
        }

        return $request->wantsJson()
            ? new JsonResponse([], 201)
            : redirect()->intended($this->redirectPath());
    }

关于php - 用户注册后 Laravel 5.4 Passport 重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47354860/

相关文章:

php - "raw HTTP header"是什么? "HTTP header"和 "raw HTTP header"有什么区别?

mysql - Laravel 在第一次创建模型时跳过约束违规

mysql - LaravelWhereNotIn 只有一个数字

python - 检测缩短的目的地,或 "tiny"url

.htaccess - htaccess 重定向 "/?id=(.*)",但仅限于根目录?

javascript - 阻止直接访问 js、css 文件但允许从 index.html 访问?

php - 这是在 PHP 中显示图像的最合乎逻辑的方式吗?

php - 在 Laravel 中配置电子邮件

rest - Linkedin OAuth2授权码错误

php - 如果文件在 Laravel 中上传,则文件 MIME 类型验证