Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_queryset(self):
return Session.objects.active(user=self.request.user)
def handle(self, *args, **options):
Session.objects.filter(expiration_date__lt=now()).delete()
self.stdout.write(self.style.SUCCESS('Deleted expired sessions'))
def create_session(sender, request, user, **kwargs):
Session.objects.create_session(request, user)
def deactivate_session(sender, request, user, **kwargs):
try:
key = request.session.session_key
instance = Session.objects.get(user=user, session_key=key)
instance.active = False
instance.save()
except Session.DoesNotExist:
pass