Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 11 - This password does not use the Bcrypt algorithm

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 ?

like image 378
l3mon_ Avatar asked Aug 31 '25 23:08

l3mon_


1 Answers

In my case the problem solved when i change my hashed password in database from starting '$2a$' to '$2y$'

eg: $2a$12$POGG9oYZvS/8ijd8PiA3Q.bxTMMv4Ca77nIdZ6VFOEJOQGtM4ltUC

to this, $2y$12$POGG9oYZvS/8ijd8PiA3Q.bxTMMv4Ca77nIdZ6VFOEJOQGtM4ltUC

like image 128
Dhanush J.A Avatar answered Sep 04 '25 04:09

Dhanush J.A