Name
Name

Reputation: 408

Laravel Auth::attempt always return false?

Here is myscreen shot of database and my login input enter image description here

public function action(Request $request){
         $username = $request->username;
         $pass = bcrypt($request->password);
         $credentials = [
                         'id' => $username,
                         'password' => $pass
                        ];

    dd(Auth::attempt($credentials));
         if (Auth::attempt(['id' => $username, 'password' => $pass])) {
            echo 'Ok';
         }else{
            echo 'Not ok';
         }

I'm trying to make a login action using laravel auth::attemptbut it always return false.

Upvotes: 0

Views: 187

Answers (1)

Karl
Karl

Reputation: 5473

$pass = bcrypt($request->password);

should be

$pass = $request->password;

The attempt method will automatically handle the encryption and comparison. You are in effect bcrypting it twice, so a match isn't found

Upvotes: 3

Related Questions