-1

I'm running a laravel API with a login page and a nuxt.js application which authenticates a user through oauth.

The whole authorization flow is working, but after successfully logging out in the nuxt.js app a user is not asked for user credentials anymore on further logins.

How can I manage that the user is asked for his credentials again on next login?

Question is similar to this but I don't want to delete any authorization tokens, I want user to again login.

I already created a custom endpoint in my api but it doesn't seem to work:

    public function logoutApi()
    {
        Auth::guard('web')->logout();
        $cookie = \Cookie::forget('laravel_session');
        \Session::flush();

        return response('User has been logged out.')->cookie($cookie);
    }

Any ideas?

4
  • 1
    Why don't want to delete the authorization tokens? Commented Aug 1, 2019 at 13:24
  • So far I know deleting auth token is part of oauth flow Commented Aug 1, 2019 at 13:28
  • @fez because if I delete the auth token user has just to again click on a "Authorize" button, not completely log in Commented Aug 1, 2019 at 13:30
  • Btw session::flush will delete all user access Commented Aug 1, 2019 at 13:36

1 Answer 1

0

This will revoke a user's access to the token but the token won't be deleted

if (Auth::check()) {
    $user = Auth::user()->token();
    $user->revoke();
}
Sign up to request clarification or add additional context in comments.

1 Comment

It also needs use Illuminate\Support\Facades\Auth;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.