canaille-globuzma/canaille/oidc/commands.py
2024-03-15 19:58:37 +01:00

23 lines
496 B
Python

import click
from flask.cli import with_appcontext
from canaille.app import models
from canaille.app.commands import with_backendcontext
@click.command()
@with_appcontext
@with_backendcontext
def clean():
"""Remove expired tokens and authorization codes."""
for t in models.Token.query():
if t.is_expired():
t.delete()
for a in models.AuthorizationCode.query():
if a.is_expired():
a.delete()
def register(cli):
cli.add_command(clean)