Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent logout after updating user password in Laravel 5.5

Beginning with Laravel 5.3, this middleware was added...

\Illuminate\Session\Middleware\AuthenticateSession

While it's definitely a benefit for security purposes, it's also responsible for logging the user out (presenting the user with the login page) if they change their password.

How do we prevent a user from being logged out (being forced to log back in) when they change their password, in Laravel 5.5?

like image 621
mcpacific Avatar asked Nov 07 '17 00:11

mcpacific


1 Answers

Instead of changing the middleware, just "re-login" the user after changing the password:

<?php
//$user->passwordChangeMagicHere()

Auth::login($user);
//And the user is logged in again!
like image 183
manniL Avatar answered Sep 25 '22 18:09

manniL