Laravel 5.2: Multi authentication always returns false

0

Always returning error when making login , even though the data is correct. I have already seen several topics about this error, but none have solved the problem.

CONTROLLER

public function cadastro(Request $request)
{
    $dataForm = $request->all();

    $dataForm['password'] = bcrypt($dataForm['password']);

    $cliente = $this->cliente->create($dataForm);
}

public function login(Request $request)
{
    $credentials = ['email' => $request->email, 'password' => $request->password];

    if(Auth::guard('cliente')->attempt($credentials)) {
        echo 'OK';
    } else {
        echo 'ERRO';
    }
}

MODEL

class Cliente extends Authenticatable
{
    protected $table = 'clientes';
    protected $dates = ['created_at','updated_at'];
    protected $fillable = ['nome', 'sobrenome', 'email', 'password'];
    protected $hidden = ['password'];
}

AUTH

return [

    'defaults' => [
        'guard' => 'web',
        'passwords' => 'users',
    ],

    'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],

        'cliente' => [
            'driver' => 'session',
            'provider' => 'clientes',
        ],

        'api' => [
            'driver' => 'token',
            'provider' => 'users',
        ],
    ],

    'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => App\User::class,
        ],

        'clientes' => [
            'driver' => 'eloquent',
            'model' => App\Cliente::class,
        ],
    ],
];

I am creating the table without migration , ie directly in the database:

CREATE TABLE clientes(id int auto_increment, 
                     nome varchar(50), 
                     sobrenome varchar(50), 
                     email varchar(50), 
                     password varchar(50), 
                     created_at datetime, 
                     updated_at datetime, 
                     primary key(id));
    
asked by anonymous 19.01.2018 / 13:39

1 answer

0

bcrypt takes up more than 50 characters, so I resized the database to 100 and the problem has been solved!

    
19.01.2018 / 15:00