Created
August 27, 2019 07:38
-
-
Save akoepcke/3da2290ac2f00f1aa8562c61ba8b2fb8 to your computer and use it in GitHub Desktop.
migrate md5 to bcrypt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected function attemptLogin(Request $request) | |
{ | |
$check = $this->guard()->attempt( | |
$this->credentials($request), $request->has('remember') | |
); | |
if ($check === false) | |
{ | |
$user = User::where('username','=',$request->input('username'))->first(); | |
if(isset($user)) { | |
// If their password is still MD5 | |
if($user->password == md5($request->input('password'))) { | |
// Convert to new format | |
$hashed_password = Hash::make($request['password']); | |
$user->password = $hashed_password; | |
$user->save(); | |
$request->session()->regenerate(); | |
$this->clearLoginAttempts($request); | |
Auth::login($user, true); | |
return true; | |
} else { | |
// Redirect to the login page. | |
return false; | |
} | |
} | |
} | |
return $check; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment