-
-
Notifications
You must be signed in to change notification settings - Fork 549
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.x] Logout user from other devices when changing password #10548
[5.x] Logout user from other devices when changing password #10548
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check out this flow:
- Browser 1 and Browser 2 are both logged into the same account
- Browser 1 changes the password
- Browser 2 tries to navigate to another page in the CP
- Browser 2 gets an error about a login route
By default that middleware redirects to a route named login
. I think you should call AuthenticateSession::redirectUsing(fn () => cp_route('login'))
. But somehow only when it's a CP route. If someone is using that middleware on the frontend, you don't want to hijack the redirect.
Good catch! I've added that into the |
Does this fix work if it's an admin changing the user's pw? I think it has to as well. |
src/Providers/CpServiceProvider.php
Outdated
? cp_route('login') | ||
: config('statamic.cp.auth.redirect_to', '/'); | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still going to redirect to the CP on a non-CP page.
I meant if you use the middleware on a front-end route you don't want to get taken to the CP. In those cases, we want to just not call this method, and let them deal with it themselves. e.g. Keep the login
route or have them adjust it.
Maybe we can have another earlier middleware that gets run for CP routes that calls this method.
Right now, no. But I agree that it should. I just thought about this chunk of code: if ($currentPassword = $request->current_password) {
Auth::logoutOtherDevices($currentPassword);
} That shouldn't be the way to do it. The password has been changed by that point, so the new password ( We should be able to do I'm not sure where the issue lies. Still looking into it. 🤔 |
Actually, scratch that. The |
@jasonvarga Hmm. Maybe you don't need |
You're right! |
This was true, but it also logged out the current user. Adding Auth::login() to log the user back in addressed this. |
This pull request makes it so when a user changes their own password, it'll log them out from their other devices.
Fixes #10524.