@Snapey, you're absolutely correct. The issue in my case stemmed from double hashing the password. Initially, during the password reset process, Laravel Fortify actions automatically hash the password within the reset method
public function reset(User $user, array $input): void
{
Validator::make($input, [
'password' => $this->passwordRules(),
])->validate();
$user->forceFill([
'password' => Hash::make($input['password']),
])->save();
}
However, I had also implemented a mutator for the password field, which further hashed the password value. To resolve this, I revised the mutator as follows:
public function setPasswordAttribute($value)
{
// Check if the given password is already hashed
if (Hash::needsRehash($value)) {
// If it is not hashed, hash it before setting the attribute
$this->attributes['password'] = Hash::make($value);
} else {
// If it is already hashed, don't hash it again
$this->attributes['password'] = $value;
}
}
This approach ensures that passwords are hashed only when necessary, preventing double hashing and login issues. However, I'm curious if there's a more optimal solution or if there are any best practices to handle this scenario.
Any insights or suggestions would be greatly appreciated. Thank you!