Laravel 5 Override Login Function

前端 未结 3 1820
挽巷
挽巷 2021-01-14 17:05

I\'m working on my Laravel Project and trying to override the default postLogin() from AuthenticatesAndRegistersUsers . So I have updated my AuthController and added this t

3条回答
  •  再見小時候
    2021-01-14 17:19

    Try following this discussion at laracasts.

    Here is a solution

    if ($this->guard()->validate($this->credentials($request))) {
            $user = $this->guard()->getLastAttempted();
            if ($user->is_activated && $this->attemptLogin($request)) {
                return $this->sendLoginResponse($request);
            } else {
                $this->incrementLoginAttempts($request);
                if ($request->ajax()) {
                    return response()->json([
                        'error' => 'This account is not activated.'
                    ], 401);
                }
            }
        }
    

    It provided a crucial update for a do my homework service at Top Homework Expert

提交回复
热议问题