When implementing Laravel 5.4 Passport and calling /oauth/authorize , with the requisite parameters, the Auth middleware redirects to /login when no session is found. Upon logging in a redirect is made back to the /oauth/authorize route to complete the process.
This is working as expected.
However, if we need the user to instead register prior to authorizing then the intended /oauth/authorize uri is no longer redirected to after successfully registration.
I've poured through the middleware and the auth framework code. Only coming up with Redirect::intended()
, which is based on a session key of url.intended
, but this is null even at the point of showing /login .
Any clues how I could redirect back to the /oauth/authorize page upon registration?
Add this code in RegisterController you need to redirect it using redirect()->intended($this->redirectPath()) instead of 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());
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.