douxi3404 2016-05-23 02:45
浏览 72

Laravel登录用户

I am a bit of a newbie to Laravel and I have setup a table User with fields username and password.

My sign in screen has a form with these fields duly declared and I have a function is UserController:

public function SignIn(Request $request)
{
    $this->validate($request,
        [
            'username' => 'required',
            'password' => 'required'
        ]);

    if (Auth::attempt([ 'username' => $request['username'], 'password' =>$request['password'] ]) )
    {
        return redirect()->route('dashboard');
    }
    else
    {
        return redirect()->back();
    }
}

I know it is getting there OK because I can see the error messages if I submit the form blank.

I have removed the default User Auth.

When I submit I get:

ErrorException in EloquentUserProvider.php line 114: Argument 1 passed to Illuminate\Auth\EloquentUserProvider::validateCredentials() must be an instance of Illuminate\Contracts\Auth\Authenticatable, instance of App\User given, called in /home/sites/mysticsisterfilms.com/public_html/admin/protected/vendor/laravel/framework/src/Illuminate/Auth/SessionGuard.php on line 378 and defined

Can someone please point me in the right direction?

  • 写回答

1条回答 默认 最新

  • duanlu6268 2016-05-26 14:25
    关注

    A simple answer which I hope will be useful. In my database I had put the password in "as it were", ie mypassword.

    Laravel assumes it is encrypted so of course it was always returning no match

    评论

报告相同问题?

悬赏问题

  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line