php – Laravel 5.2自定义身份验证错误
发布时间:2020-12-14 19:55:55 所属栏目:大数据 来源:网络整理
导读:我为我的laravel 5.2进行自定义身份验证时收到错误但是此代码在我的laravel 5.1 My config / auth.php文件中正常工作 'providers' = [ 'users' = [ 'driver' = 'custom','model' = AppUser::class,],// 'users' = [ // 'driver' = 'database',// 'table' =
我为我的laravel 5.2进行自定义身份验证时收到错误但是此代码在我的laravel 5.1 My config / auth.php文件中正常工作
'providers' => [ 'users' => [ 'driver' => 'custom','model' => AppUser::class,],// 'users' => [ // 'driver' => 'database',// 'table' => 'users',// ], 我的CustomUserProvider.php(Auth / CustomUserProvider)文件 <?php namespace AppAuth; use IlluminateContractsAuthUserProvider; use IlluminateContractsHashingHasher as HasherContract; use IlluminateContractsAuthAuthenticatable as UserContract; class CustomUserProvider implements UserProvider { protected $model; public function __construct(UserContract $model) { $this->model = $model; } public function retrieveById($identifier) { } public function retrieveByToken($identifier,$token) { } public function updateRememberToken(UserContract $user,$token) { } public function retrieveByCredentials(array $credentials) { } public function validateCredentials(UserContract $user,array $credentials) { } } 我的CustomAuthProvider.php文件 <?php namespace AppProviders; use AppUser; use Auth; use AppAuthCustomUserProvider; use IlluminateSupportServiceProvider; class CustomAuthProvider extends ServiceProvider { /** * Bootstrap the application services. * * @return void */ public function boot() { $this->app['auth']->extend('custom',function() { return new CustomUserProvider(); }); } /** * Register the application services. * * @return void */ public function register() { // } } 现在这在laravel 5.1 in 5.2中工作正常我得到的错误就像 InvalidArgumentException in CreatesUserProviders.php line 40: Authentication user provider [custom] is not defined.
唯一的一点是使用
$this->app['auth']->provider(... 代替 $this->app['auth']->extend(... 最后一个在5.1中使用,第一个应该在5.2中使用. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |