Error during Auth::attempt($credentials)
. Followed https://laravel.com/docs/11.x/authentication#authenticating-users
I’ve created simple seeder:
$hashedPassword = Hash::make('password');
User::factory()->create([
'name' => 'Admin User',
'login' => 'admin',
'password' => $hashedPassword,
'role' => 'Admin',
]);
Phpmyadmin
I am trying to log in user with
public function loginUser(Request $request)
{
$credentials = $request->only('login', 'password');
if (Auth::attempt($credentials)) {
$request->session()->regenerate();
return redirect()->intended('/');
}
return back()->withErrors(['login' => 'Invalid login or password']); // Redirect back with error message
}
I am getting error even if password in DB is hashed. Did I miss something ?
New contributor
l3mon_ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.