AGuier

497 经验值

config/app.php
配置

providers =>
Jenssegers\Mongodb\MongodbServiceProvider::class,
Jenssegers\Mongodb\Auth\PasswordResetServiceProvider::class,
aliases=>'Moloquent' => 'Jenssegers\Mongodb\Model',

登录是用的auth原生app\User.php

基本没什么变化和自动生成的 就是改了下表和继承的 Model 这都是 拓展包自带的

use Jenssegers\Mongodb\Model as Eloquent;

class User extends Eloquent {
    use Authenticatable, Authorizable, CanResetPassword;

    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $collection = 'system_user';

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['username', 'password','email','roleId','status'];

    /**
     * The attributes excluded from the model's JSON form.
     *
     * @var array
     */
    protected $hidden = ['password', 'remember_token'];
}

Bug出现的文件
vendor/laravel/framework/src/Illuminate/Auth/Guar.php

    public function attempt(array $credentials = [], $remember = false, $login = true)
    {
        $this->fireAttemptEvent($credentials, $remember, $login);

        $this->lastAttempted = $user = $this->provider->retrieveByCredentials($credentials);
        //dd($user);
        // 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 提示没实例。。。

提示的内容:

ErrorException in EloquentUserProvider.php line 110:
Argument 1 passed to Illuminate\Auth\EloquentUserProvider::validateCredentials() must be an instance of Illuminate\Contracts\Auth\Authenticatable, instance of App\User given, called in /alidata/www/laravel-system/vendor/laravel/framework/src/Illuminate/Auth/Guard.php on line 390 and defined