canaille-globuzma/canaille/oidc/commands.py

23 lines
495 B
Python
Raw Normal View History

import click
from canaille.app import models
from canaille.app.commands import with_backendcontext
from flask.cli import with_appcontext
@click.command()
@with_appcontext
@with_backendcontext
def clean():
2023-12-28 17:31:57 +00:00
"""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)