public function validateCredentials(UserContract $user, array $credentials)
{
$plain = $credentials['password'];
return $this->hasher->check($plain, $user->getAuthPassword());
}
如何在类
validateCredentials
中覆盖方法EloquentUserProvider
?谢谢! 最佳答案
您可以创建自己的UserProvider,然后可以覆盖原始UserProvider中的功能。
首先,您创建CustomUserProvider:
use Illuminate\Contracts\Auth\UserProvider;
use Illuminate\Contracts\Auth\Authenticatable as UserContract;
class CustomUserProvider extends UserProvider {
public function validateCredentials(UserContract $user, array $credentials)
{
$plain = $credentials['password'];
return $this->hasher->check($plain, $user->getAuthPassword());
}
}
然后,您在config / app.php中注册新的CustomUserProvider
'providers' => array(
... On the bottom, must be down to override the default UserProvider
'Your\Namespace\CustomUserProvider'
),
关于laravel - Laravel 5.4 EloquentUserProvider覆盖validateCredentials,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44069557/