I use:
public function postRegister(Request $request){
$request->validate([
'Email' => 'required|unique:users,Email',
'Password' => ['required'],
]);
$user = new User;
$user->Email = $request->Email;
$user->Password = Hash::make($request->password);
$user->save();
auth()->login($user);
return redirect()->route('user.home');
}
for my register function in laravel 10. It worked correctly and stores a new user in the database and the password was hashed correctly.
Register page:
Database saved the new user and hashed password:
Then I tried to login by using:
public function postLogin(Request $request)
{
$credentials = $request->validate([
'email' => ['required', 'email'],
'password' => ['required'],
]);
if(Auth::attempt($credentials)){
return redirect()->route('user.home');
}
else return back()->withErrors([
'Email' => 'Wrong email or password',
])->onlyInput('Email');
}
in laravel 10.
Login page:
It comes up with an error:
This password does not use the Bcrypt algorithm.
Error:
I don’t know where I went wrong, please help me.
2
Answers
I had this problem too and solved it in a non-obvious way. In general, if you have users with unhashed password in the users table, delete them. I had users without hashed password and only after I deleted them everything worked. I don’t know why it works like that, but whatever. Full code:
I used this site(https://bcrypt.online/) to create a password and my problem was solved.