File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -68,6 +68,16 @@ def _get_subject_id(session):
6868 return None
6969
7070
71+ def callable_bool (value ):
72+ """ A compatibility wrapper for pre Django 1.10 User model API that used
73+ is_authenticated() and is_anonymous() methods instead of attributes
74+ """
75+ if callable (value ):
76+ return value ()
77+ else :
78+ return value
79+
80+
7181def login (request ,
7282 config_loader_path = None ,
7383 wayf_template = 'djangosaml2/wayf.html' ,
@@ -109,7 +119,7 @@ def login(request,
109119 # SAML_IGNORE_AUTHENTICATED_USERS_ON_LOGIN setting. If that setting
110120 # is True (default value) we will redirect him to the came_from view.
111121 # Otherwise, we will show an (configurable) authorization error.
112- if request .user .is_authenticated :
122+ if callable_bool ( request .user .is_authenticated ) :
113123 redirect_authenticated_user = getattr (settings , 'SAML_IGNORE_AUTHENTICATED_USERS_ON_LOGIN' , True )
114124 if redirect_authenticated_user :
115125 return HttpResponseRedirect (came_from )
You can’t perform that action at this time.
0 commit comments