这是 laravel 用于身份验证的函数。如果你在这里看到:vendor/laravel/framework/src/illuminate/Auth/Guard.php
public function attempt(array $credentials = array(), $remember = false, $login = true)
{
$this->fireAttemptEvent($credentials, $remember, $login);
$this->lastAttempted = $user = $this->provider->retrieveByCredentials($credentials);
// If an implementation of UserInterface was returned, we'll ask the provider
// to validate the user against the given credentials, and if they are in
// fact valid we'll log the users into the application and return true.
if ($this->hasValidCredentials($user, $credentials))
{
if ($login) $this->login($user, $remember);
return true;
}
return false;
}
如果您通过源代码查看此功能,请使用 hasValidCredentials 功能,如果您进一步挖掘,该功能是:
protected function hasValidCredentials($user, $credentials)
{
return ! is_null($user) && $this->provider->validateCredentials($user, $credentials);
}
在 UserProviderInterface 接口中,您会看到该接口已被定义,您可以自己实现它并返回身份验证问题的原因,而不是 false 或 true