Skip to content

Commit

Permalink
Call is_authenticated property instead of function for Django 2.0 (#98)
Browse files Browse the repository at this point in the history
* Call is_authenticated property instead of function for Django 2.0 compatibility

* Check django version
  • Loading branch information
tpeaton authored and jpic committed Dec 22, 2017
1 parent 6249e41 commit 6484f97
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion session_security/middleware.py
Expand Up @@ -11,6 +11,7 @@

from datetime import datetime, timedelta

import django
from django.contrib.auth import logout
from django.core.urlresolvers import reverse, resolve, Resolver404

Expand Down Expand Up @@ -51,7 +52,12 @@ def get_expire_seconds(self, request):

def process_request(self, request):
""" Update last activity time or logout. """
if not request.user.is_authenticated():
if django.VERSION < (1, 10):
is_authenticated = request.user.is_authenticated()
else:
is_authenticated = request.user.is_authenticated

if not is_authenticated:
return

now = datetime.now()
Expand Down

0 comments on commit 6484f97

Please sign in to comment.