whatthef's avatar

Passport test logout after actingAs

How can I test logout using passport after actingAs? Token revoke doesn't seem to work

0 likes
5 replies
martinbean's avatar

@whatthef You don’t “log out” when using token-based authentication. The token is either valid or not.

whatthef's avatar

@martinbean Yes sorry for the wrong wording how can I make the token invalid? $token->revoke() or $token->delete() don't work

whatthef's avatar

@martinbean So there is no way to test the token invalidation with Passport::actingAs? I see it uses Auth::setUser but it doesn't work with Auth::setUser(null).

martinbean's avatar

@whatthef No, because like I say: the token is a mock and not an actual token. It’s a test helper.

If you want to test your application with a revoked token, then you’re going to need to generate an actual token yourself and persist it to the database so it can be revoked.

Please or to participate in this conversation.