How to use the safety.models.Session.objects function in safety

To help you get started, we’ve selected a few safety examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ulule / django-safety / safety / mixins.py View on Github external
def get_queryset(self):
        return Session.objects.active(user=self.request.user)
github ulule / django-safety / safety / management / commands / clean_safety_sessions.py View on Github external
def handle(self, *args, **options):
        Session.objects.filter(expiration_date__lt=now()).delete()
        self.stdout.write(self.style.SUCCESS('Deleted expired sessions'))
github ulule / django-safety / safety / models.py View on Github external
def create_session(sender, request, user, **kwargs):
    Session.objects.create_session(request, user)
github ulule / django-safety / safety / models.py View on Github external
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