多次认证登录错误

时间:2016-01-05 07:15:04

标签: authentication login laravel-5

我正在进行多重身份验证 我的前端有一个带cardno和密码的登录表单。 在auth.php中

public void OnOperatorBtnClick(object sender, RoutedEventArgs args)
{
    Button operatorBtnClick = (Button)sender;
    EqualsRepeated = false;
    if (isOperationPerformed == false)
    {
        if (xResultNumber != 0)
        {
            OnEqualsBtnClick(this, new RoutedEventArgs());
            operationPerformed = (string)operatorBtnClick.Content;
            isOperationPerformed = true;
            EqualsRepeated = false;
        }
        else
        {
            operationPerformed = (string)operatorBtnClick.Content;
            xResultNumber = Double.Parse(OutputValue);
            isOperationPerformed = true;
        }
    }
    else
    {
        //Do nothing. 
    }
}

public void OnEqualsBtnClick(object sender, RoutedEventArgs args)
{
    if (EqualsRepeated == false)
    {
        if (double.TryParse(OutputValue, out yResultNumber))
            switch (operationPerformed)
            {
                case "+":
                    {
                        OutputValue = (xResultNumber + yResultNumber).ToString();
                        break;
                    }
            }
        isOperationPerformed = true;
        EqualsRepeated = true;
    }
    else
    {
        // If equals has already been clicked
        if (EqualsRepeated == true)
            if (double.TryParse(OutputValue, out xResultNumber))
                switch (operationPerformed)
                {
                    case "+":
                        {
                            OutputValue = (xResultNumber + yResultNumber).ToString();
                            break;
                        }
                }
    }
    isOperationPerformed = false;
    xResultNumber = 0;
}

在route.php中

return [
        'multi' => [
            'users' => [
                'driver' => 'eloquent',
                'model'  => App\User::class,
                'table'  => 'users'
            ],
            'frontendUsers' => [
                'driver' => 'eloquent',
                'model'  => App\loginModel::class,
                'table'  => 'frontend_users'
            ]
         ],
         'password' => [
                'email' => 'emails.password',
                'table' => 'password_resets',
                'expire' => 60,
            ],
        ];
在logincontroller中

Route::post('login','auth\loginController@postLogin');

在loginModel.php中

public function postLogin(Request $request){
....
    // attempt to do the login
    if (\Auth::attempt('frontendUsers', ['cardno' => '111111', 'password' => '999087787'])) {
           echo "login";
    }
    else {
            echo "failed";
    }
}

当我尝试登录时,我收到此错误

  

EloquentUserProvider.php第110行中的ErrorException:参数1已通过   到Illuminate \ Auth \ EloquentUserProvider :: validateCredentials()必须是   Illuminate \ Contracts \ Auth \ Authenticatable的实例,实例   App \ loginModel给定,调用   C:\ XAMPP \ htdocs中\ elitecard \厂商\ laravel \框架\ SRC \照亮\验证\ Guard.php   在第390行并定义

2 个答案:

答案 0 :(得分:0)

在你的模型loginModel中,尝试使用名为“Authenticatable”的特征,或者改用Users模型。

答案 1 :(得分:0)

您必须在模型中实施合同{​​{1}},并使用特征Illuminate\Contracts\Auth\Authenticatable。要在类中使用特征,必须在类中编写use语句。您的loginModel的开头应该是这样的:

Illuminate\Auth\Authenticatable