first(); if (! $user) { return; } $hashed = $user->password; // Check if the password is already hashed using bcrypt if (!Hash::needsRehash($hashed)) { if (!Hash::check($password, $hashed)) { return; } } // If the password is hashed using MD5, verify and upgrade to bcrypt elseif (md5($password) !== $hashed) { return; } else { $user->password = Hash::make($password); $user->save(); } return new User($user->getAuthIdentifier()); } }