2020-10-23 09:31:16 +00:00
|
|
|
from flask import Blueprint, current_app
|
|
|
|
from canaille.models import AuthorizationCode, Token
|
|
|
|
|
|
|
|
|
|
|
|
bp = Blueprint("commands", __name__)
|
|
|
|
|
|
|
|
|
|
|
|
@bp.cli.command("clean")
|
|
|
|
def clean():
|
2020-10-23 10:20:27 +00:00
|
|
|
from canaille import setup_ldap, teardown_ldap
|
2020-10-23 09:31:16 +00:00
|
|
|
|
|
|
|
setup_ldap(current_app)
|
|
|
|
|
|
|
|
for t in Token.filter():
|
|
|
|
if t.is_expired():
|
|
|
|
t.delete()
|
|
|
|
|
|
|
|
for a in AuthorizationCode.filter():
|
|
|
|
if a.is_expired():
|
|
|
|
a.delete()
|
|
|
|
|
2020-10-23 10:20:49 +00:00
|
|
|
teardown_ldap(current_app)
|