Method Illuminate\Auth\RequestGuard::attempt does not exist

后端 未结 2 1926
名媛妹妹
名媛妹妹 2021-02-19 07:54

I am new to both laravel and lumen. I was creating a login api with oauth2.0 in lumen 5.6, i have installed passport and generated token. Below is my login controller function a

相关标签:
2条回答
  • 2021-02-19 08:30

    The function guard is only available for routes with web middleware

    public function login() {
    
      if(Auth::guard('web')->attempt(['email' => $email, 'password' => $password], false, false)) {requests
         // good
      } else {
        // invalid credentials, act accordingly
     }
    }
    
    0 讨论(0)
  • 2021-02-19 08:33

    Changing default guard to "web" fixed my problem.

    config/auth.php:

    'defaults' => [
            'guard' => 'web',
            'passwords' => 'users',
        ],
    
    0 讨论(0)
提交回复
热议问题