目前,我正在一个laravel 5项目。 我想用我的自定义加密密码,所以我做了一个功能,我尝试使用它。 首先,我重写postLogin函数,并添加了新密码Encryption。自定义身份验证和密码加密laravel 5
public function postLogin(Request $request)
{
$email = $request->get('email');
$password = $this->hashPassword($request->get('password'));
$this->validate($request, [
$this->loginUsername() => 'required', 'password' => 'required',
]);
// If the class is using the ThrottlesLogins trait, we can automatically throttle
// the login attempts for this application. We'll key this by the username and
// the IP address of the client making these requests into this application.
$throttles = $this->isUsingThrottlesLoginsTrait();
if ($throttles && $this->hasTooManyLoginAttempts($request)) {
return $this->sendLockoutResponse($request);
}
$credentials = ['email' => $email, 'password' => $this->hashPassword($password)];
if (Auth::attempt(['email' => $email, 'password' => $this->hashPassword($password)])) {
// Authentication passed...
return $this->handleUserWasAuthenticated($request, $throttles);
}
// If the login attempt was unsuccessful we will increment the number of attempts
// to login and redirect the user back to the login form. Of course, when this
// user surpasses their maximum number of attempts they will get locked out.
if ($throttles) {
$this->incrementLoginAttempts($request);
}
return redirect($this->loginPath())
->withInput($request->only($this->loginUsername(), 'remember'))
->withErrors([
$this->loginUsername() => $this->getFailedLoginMessage(),
]);
}
正如你可以在代码中看到,我调用的函数hashPassword,和这样的作品,但问题是,“验证::尝试”返回false往常一样,尽管我有我的数据库中的用户,用正确的数据。
任何解决方案,请?
非常感谢
亲切的问候