Skip to content

Commit 6db9646

Browse files
committed
Treat User is_anonymous/authenticated as attribute instead of function
1 parent 3a69f68 commit 6db9646

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

djangosaml2/views.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,8 @@ def login(request,
109109
# SAML_IGNORE_AUTHENTICATED_USERS_ON_LOGIN setting. If that setting
110110
# is True (default value) we will redirect him to the came_from view.
111111
# Otherwise, we will show an (configurable) authorization error.
112-
if not request.user.is_anonymous():
113-
try:
114-
redirect_authenticated_user = settings.SAML_IGNORE_AUTHENTICATED_USERS_ON_LOGIN
115-
except AttributeError:
116-
redirect_authenticated_user = True
117-
112+
if request.user.is_authenticated:
113+
redirect_authenticated_user = getattr(settings, 'SAML_IGNORE_AUTHENTICATED_USERS_ON_LOGIN', True)
118114
if redirect_authenticated_user:
119115
return HttpResponseRedirect(came_from)
120116
else:

0 commit comments

Comments
 (0)