douban5644 2019-05-07 16:43
浏览 79

如何基于UserProvider创建自定义提供程序并正确注册

How to create a custom provider based on UserProvider and register it properly. I want to create a custom way of comparing passwords. I have the following:

StaffServiceProvider

<?php

namespace App\Providers;

use Illuminate\Auth\EloquentUserProvider as UserProvider;
use Illuminate\Contracts\Auth\Authenticatable as UserContract;


class StaffServiceProvider extends UserProvider {

    public function validateCredentials(UserContract $user, array $credentials)
    {
        $plain = $credentials['password'];
        if (sha1($plain) == $user->getAuthPassword()) {
            return true;
        } else {
            return false;
        }
    }

}

config/app.php

    'providers' => [
      ...

//      CUSTOM
        App\Providers\StaffServiceProvider::class,

and I'm getting this error. How do I fix it

Argument 1 passed to Illuminate\Auth\EloquentUserProvider::__construct() must be an instance of Illuminate\Contracts\Hashing\Hasher, instance of Illuminate\Foundation\Application given, called in C:\xampp\htdocs\zeemed\vendor\laravel\framework\src\Illuminate\Foundation\ProviderRepository.php on line 208
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 怎么获取下面的: glove_word2id.json和 glove_numpy.npy 这两个文件
    • ¥15 js调用html页面需要隐藏某个按钮
    • ¥15 ads仿真结果在圆图上是怎么读数的
    • ¥20 Cotex M3的调试和程序执行方式是什么样的?
    • ¥20 java项目连接sqlserver时报ssl相关错误
    • ¥15 一道python难题3
    • ¥15 牛顿斯科特系数表表示
    • ¥15 arduino 步进电机
    • ¥20 程序进入HardFault_Handler
    • ¥15 oracle集群安装出bug