Search code examples
laravel-5basic-authentication

Can't validate user attempt


I'm using laravel 5.0 and I can't validate the login.
If I type a wrong match of email/pass, it redirects me perfect.
But when I type a correct email/pass then it returns me this:

Argument 1 passed to Illuminate\Auth\EloquentUserProvider::validateCredentials() must be an instance of Illuminate\Contracts\Auth\Authenticatable, instance of App\User given ...

I'm following the documentation and it looks like everything is allright.

Model:

<?php namespace App;

use Illuminate\Database\Eloquent\Model;

class User extends Model {  

}  

Controller

public function postsignin(Request $request)
    {
        if( Auth::attempt( ['email' => $request['email'], 'password' => $request['password'] ] ) )
            return redirect()->route('dashboard');
        return redirect()->back();
    }  

No idea what it is.


Solution

  • try to implement the AuthenticatableContract and Authenticatable trait

    <?php namespace App;
    
    use Illuminate\Auth\Authenticatable;
    use Illuminate\Database\Eloquent\Model;
    use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
    
    class User extends Model implements AuthenticatableContract{  
        use Authenticatable
    }