1
I’m trying to do a custom login with Laravel 6, but it’s not working.
I have the following code:
public function postLogin(Request $request)
{
request()->validate([
'email' => 'required',
'senha' => 'required',
]);
$credentials = $request->only('email', 'senha');
if (Auth::attempt($credentials)) {
return redirect()->intended('dashboard');
}
return Redirect::to("login")->withSuccess('Oppes! You have entered invalid credentials');
}
Knowing that, Laravel works with its standard variables like email and password, I already changed in model
class User extends Authenticatable
{
use Notifiable;
protected $table = 'usuarios';
public $timestamps = false;
protected $fillable = ['email', 'senha', 'nivel_id', 'data_cadastro', 'status', 'assinante', 'site_id', 'tipo_conta_id'];
}
In BD the columns are with the names of: "email" and "password", I believe I have to change this name pattern, instead of "password", change to "password", because when I try to debug Auth::attempt($credentials)
he always returns false.
Already tried to specify the name of the fields in
Auth::attempt()
? guyAuth::attempt(['email' => $credentials['email'], 'senha' => $credentials['senha'])
– gmsantos
I took the dd test (Auth::Attempt(['email' => $credentials['email'], 'password' => $credentials['password'] ]); and false return still
– Rafael Moura
one option is to exchange your bank for password then
– gmsantos
the problem that the bank is not my kkkk
– Rafael Moura
for testing, I changed here in the database to password and returned true, now I need to know how to do it in the Language
– Rafael Moura
you can create a new Migration to change this field
– gmsantos
Does this Answer your Question? Customizing a user model Laravel 5.4 - Login problem
– novic
related: https://answall.com/questions/381991/fazendo-login-no-laravel-password-sem-hash/381997#381997
– novic