Answer the question
In order to leave comments, you need to log in
Laravel how to correctly change hashing during authentication?
Hello!
I am working on a small project. I decided to do it on Laravel, and at the same time study this framework.
There are still misunderstandings in many things.
There is already a database with user data. The password storage format is different from laravel. Need this type: md5(bin2hex(str))
Registration is not required. But there is a problem with the login. Found one of the options, changed the method here:
vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php
public function validateCredentials(UserContract $user, array $credentials)
{
$plain = $credentials['password'];
if (md5(bin2hex($plain)) == $user->getAuthPassword()) {
return true;
} else {
return false;
}
// return $this->hasher->check($plain, $user->getAuthPassword());
}
Answer the question
In order to leave comments, you need to log in
It may be enough to add your own hasher, implement interface methods:
use Illuminate\Contracts\Hashing\Hasher;
use Illuminate\Hashing\AbstractHasher;
class CustomHasher extends AbstractHasher implements Hasher
{}
app('hash')->extend('custom_hasher', function () {
return new CustomHasher();
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question