Avoiding laravel from redirecting user after login

Posted 2 years ago by anonymox

I'm trying to show "logged in" message after user logged in to my application, actually when user attempt to login for the first time I will give him/her a jwt token and I want to check if the user is logged in if user attempt to login more than once.

This is the part I have problem :

            return ($this->loginCounter > 0) ? response()->json('Logged in', 200) : ($this->CreateToken($request));

But when attemptLogin is called which will run below code it will redirect user if user is logged in :

 protected function attemptLogin(Request $request)
        return $this->guard()->attempt(
            $this->credentials($request), $request->has('remember')

IS there any way to override this ? and return "you are logged in" in response instead of redirecting to a view ?

FYI : I have customized laravel auth scafold , but this part is still making problem for me. I'm using laravel 5.3

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.