[英]Laravel 5.4 Passport redirect after user registered
当实现 Laravel 5.4 Passport 并调用/oauth/authorize 时,使用必要的参数,当找不到会话时,Auth 中间件重定向到/login 。 登录后,重定向会返回到/oauth/authorize路由以完成该过程。
这按预期工作。
但是,如果我们需要用户在授权之前注册,那么在成功注册后不再重定向到预期的/oauth/authorize uri。
我已经介绍了中间件和身份验证框架代码。 仅提出Redirect::intended()
,它基于url.intended
的会话密钥,但即使在显示/login 时也是空的。
有什么线索可以在注册时重定向回/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());
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.