当实现 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/