您好我正在尝试将laravel-permissions库中的权限检查添加到网络保护路由。
我尝试更改用户提供程序,以便我可以覆盖方法 validateCredentials 以检查有说服力的凭据,然后检查是否有权限。
然而,您似乎无法从数据库或eloquent更改config / auth.php中的驱动程序,我只是因为此检查而获得异常
Illuminate / Auth / CreatesUserProviders.php第24行
/**
* Create the user provider implementation for the driver.
*
* @param string|null $provider
* @return \Illuminate\Contracts\Auth\UserProvider|null
*
* @throws \InvalidArgumentException
*/
public function createUserProvider($provider = null)
{
if (is_null($config = $this->getProviderConfiguration($provider))) {
return;
}
if (isset($this->customProviderCreators[$driver = ($config['driver'] ?? null)])) {
return call_user_func(
$this->customProviderCreators[$driver], $this->app, $config
);
}
switch ($driver) {
case 'database':
return $this->createDatabaseProvider($config);
case 'eloquent':
return $this->createEloquentProvider($config);
default:
throw new InvalidArgumentException(
"Authentication user provider [{$driver}] is not defined."
);
}
}
您打算如何覆盖此 validateCredentials 来电? /仅允许具有laravel-permissions特定权限的用户登录网络防护