Skip to content

Commit

Permalink
fix(sessionmgmt): don't attempt to create duplicate TrustedSessions
Browse files Browse the repository at this point in the history
  • Loading branch information
anonymoose2 committed Oct 13, 2019
1 parent 284e047 commit a72dd56
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions intranet/apps/sessionmgmt/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ def trust_session_view(request):

description += request.user_agent.os.family

TrustedSession.objects.create(
user=request.user,
session_key=request.session.session_key,
description=description,
device_type=device_type,
)
if not TrustedSession.objects.filter(user=request.user, session_key=request.session.session_key).exists():
TrustedSession.objects.create(
user=request.user,
session_key=request.session.session_key,
description=description,
device_type=device_type,
)

request.session.set_expiry(7 * 24 * 60 * 60) # Trusted sessions expire after a week

Expand Down

0 comments on commit a72dd56

Please sign in to comment.