-
Notifications
You must be signed in to change notification settings - Fork 11k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[5.9] Extract registered event and login to registered method #27807
[5.9] Extract registered event and login to registered method #27807
Conversation
@antonkomarev the Laravel 6.0 upgrade guide states that you need to call the cc @driesvints |
@lindyhopchris why can't you call |
Because if I use a trait that has use RegistersUsers { registered as afterRegister; }
protected function registered($request, $user)
{
$this->afterRegister($request, $user);
return \response('my-custom response', 200);
} That's fine if that's how we're meant to use it, but I thought For Not raising this to necessarily say the approach is wrong... more to point out that what the upgrade guides currently say is wrong. |
Have you tried to implement it like this? protected function registered($request, $user)
{
parent::registered($request, $user);
return \response('my-custom response', 200);
} |
And why did you return something in Edit: I've removed that it's not designed to return anything because of |
Why does the return $this->registered($request, $user)
?: redirect($this->redirectPath()); That totally implies it's to return something other than the redirect response?! So that's the reason we've been using it to return JSON responses.... and have been since at least Laravel 5.4 (as that's the first version our app was on). If we're now meant to do it in the Currently we have this: protected function registered($request, $user)
{
if ($request->wantsJson()) {
return response()->json($user);
}
} After your changes we'd need to do: public function register($request)
{
$this->validator($request->all())->validate();
$user = $this->create($request->all());
$this->registered($request, $user); // to login and fire event.
if ($request->wantsJson()) {
return response()->json($user);
}
return redirect($this->redirectPath());
} As the parent So from our view it's a big backwards step. And the upgrade guide would have to make that clear. |
Resubmit of PR #27800 to Laravel 5.9