php – Laravel 5.2自定义身份验证错误

我为我的laravel 5.2进行自定义身份验证时收到错误但是此代码在我的laravel 5.1 My config / auth.php文件中正常工作
'providers' => [
    'users' => [
        'driver' => 'custom','model' => App\User::class,],// 'users' => [
    //     'driver' => 'database',//     'table' => 'users',// ],

我的CustomUserProvider.php(Auth / CustomUserProvider)文件

<?php namespace App\Auth;

use Illuminate\Contracts\Auth\UserProvider;
use Illuminate\Contracts\Hashing\Hasher as HasherContract;
use Illuminate\Contracts\Auth\Authenticatable 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 App\Providers;

use App\User;
use Auth;
use App\Auth\CustomUserProvider;
use Illuminate\Support\ServiceProvider;

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中使用.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


laravel的dd函数不生效怎么办
看不懂laravel文档咋办
安装laravel框架出现command怎么办
Laravel开发API怎么使用事务
laravel怎么构建复杂查询条件
laravel如何实现防止被下载
为什么laravel比yii火
一些常见的Laravel定时任务不运行的问题
laravel用路由有什么好处
composer无法安装laravel怎么办
laravel现在还用吗
laravel怎么替换主键id
laravel的appurl有什么用
如何修改Laravel的报错输出形式
laravel怎么避免foreach查表
laravel怎样操作数据库
laravel怎么截取字符串
laravel 是国内的吗
laravel怎么设置请求头
浅析Laravel社区Redis组件报错的问题和解决方法