Skip to content
Snippets Groups Projects
Commit ac8e818a authored by Art's avatar Art :lizard:
Browse files

Delete old sessions on start

parent 92815998
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ from django.db.utils import OperationalError, ProgrammingError
from django.db.models import Q
from django.contrib.auth import get_user_model
from django.utils import timezone
from django.core.management import call_command
from . import app_settings
from . import logger
from . import sso_utils
......@@ -31,10 +32,16 @@ class SSOAuthConfig(AppConfig):
# default groups
post_migrate.connect(self.post_migrate_callback, sender=self)
# cleanup
warnings = list()
try:
self.cleanup_users()
except (OperationalError, ProgrammingError,) as e:
return [Warning("ssoauth could not cleanup users. Not migrated yet?")]
warnings.append(Warning("ssoauth could not cleanup users. Not migrated yet?"))
try:
self.cleanup_sessions()
except Exception as e:
warnings.append(Warning("ssoauth could not cleanup sessions. {}".format(e)))
return warnings or None
@staticmethod
def post_migrate_callback(*args, **kwargs):
......@@ -54,3 +61,6 @@ class SSOAuthConfig(AppConfig):
user.is_staff = False
user.save()
def cleanup_sessions(self):
call_command("clearsessions")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment