Laravel 5 Auth: These credentials do not match our records.

I am just starting with Laravel 5, I came from a Laravel 4 environment, so this should not be too complicated.

I heard that the L5 comes with a built-in authentication system that is neat. I installed everything from the database to the views.

The registration process works correctly, after which it automatically enters me into the system. but when I log out and try to log in, I get this error:

These credentials do not match our records.

I'm not sure what happened. Do I need to write an input controller manually or how does it work in L5?

+4
source share
4 answers

. , setPasswordAttribute User, , , ​​.

public function setPasswordAttribute($password)
{
    $this->attributes['password'] = \Hash::make($password);
}

db: seed, Hash::make("password"). , laravel :)

laravel 5. * - Auth, Auth . {{csrf_field()}} .

+12

@mervasdayi - setPasswordAttribute :

public function setPasswordAttribute($password){
    $this->attributes['password'] = Hash::needsRehash($password) ? Hash::make($password) : $password;
}
+2

, @mervasdayi Gerard Reches. , ,

use Illuminate\Support\Facades\Hash;

at the top of your model Userwhen adding to these fixes.

+2
source

I think later, but I found two solutions to solve this problem. First, you can use the bcrypt function if you are using laravel 5.3. Take a look at the function below. This means that you are getting your data in an array.

public function create(array $data)
{
    return User::create([
        'password' => bcrypt($data['password']),
    ]);
}

Secondly, you can use the mutator to fix it as follows:

 public function setPasswordAttribute($password)
{
    $this->attributes['password'] = \Hash::make($password);
}

Hope this can help others. Regards

0
source

All Articles