2016-03-21 40 views
0

現在、私は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を返すということです適切なデータ。
解決方法はありますか?たくさん
種類よろしく

答えて

0


おかげで認証自動的にパスワードキーを提供した値をハッシュ..このような「MYPASS」や他のSTHとして「パスワード」以外の名前OKパスワードフィールドを維持してみてください。

0

解決策が見つかりました!
は、私は「ログイン」と「試み」に変更し、それは今うまく機能:D
みんなありがとう

関連する問題