From 0e9145b29ec3637e5455b185124c74a91541d115 Mon Sep 17 00:00:00 2001
From: Benjamin Bertrand <benjamin.bertrand@esss.se>
Date: Tue, 16 Jan 2018 22:20:51 +0100
Subject: [PATCH] Add command to delete expired tokens

---
 app/commands.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/app/commands.py b/app/commands.py
index 204a2c8..e608aa5 100644
--- a/app/commands.py
+++ b/app/commands.py
@@ -15,7 +15,7 @@ from flask import current_app
 from .extensions import db, ldap_manager
 from .defaults import defaults
 from .models import User
-from . import utils
+from . import utils, tokens
 
 
 def sync_user(connection, user):
@@ -73,3 +73,8 @@ def register_cli(app):
         for user in User.query.all():
             sync_user(connection, user)
         db.session.commit()
+
+    @app.cli.command()
+    def delete_expired_tokens():
+        """Prune database from expired tokens"""
+        tokens.prune_database()
-- 
GitLab