Skip to content

Instantly share code, notes, and snippets.

@akoepcke
Created August 27, 2019 07:38
Show Gist options
  • Save akoepcke/3da2290ac2f00f1aa8562c61ba8b2fb8 to your computer and use it in GitHub Desktop.
Save akoepcke/3da2290ac2f00f1aa8562c61ba8b2fb8 to your computer and use it in GitHub Desktop.
migrate md5 to bcrypt
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