Skip to content

Conversation

@gdebrauwer
Copy link
Contributor

In my project, when I user logs out, I need to revoke the access token and the refresh token linked to that access token. Currently I have to this in the following way:

auth()->user()->token()->revoke();
RefreshToken::where('access_token_id', auth()->user()->token()->id)->first()->revoke();

This PR makes that a bit easier by adding a 'refreshToken' relation to the access token model:

auth()->user()->token()->revoke();
auth()->user()->token()->refreshToken->revoke();

@taylorotwell taylorotwell merged commit b24c646 into laravel:12.x Apr 17, 2024
@alecpl
Copy link
Contributor

alecpl commented Apr 6, 2025

A better idea would be refreshTokens method, as revokeRefreshTokensByAccessTokenId is plural.

And am I missing something? If an access token can have multiple refresh tokens, how hasOne can work properly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants