Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete revoked refresh tokens on successful authentication #320

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Jake-Ransom
Copy link
Contributor

@Jake-Ransom Jake-Ransom commented Jan 8, 2024

fix: #304

Comment on lines +113 to +125
async def delete_expired_refresh_tokens(
db: AsyncSession, user_id: str, settings: Settings
) -> None:
"""Delete expired refresh tokens of a specific user"""

await db.execute(
delete(models_auth.RefreshToken).where(
models_auth.RefreshToken.expire_on
< datetime.now(timezone(settings.TIMEZONE))
)
)
await db.commit()
return None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function delete all expired tokens, instead of tokens from a specific user, but I kind of like this behaviour.

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

Successfully merging this pull request may close these issues.

Delete old refresh tokens
2 participants