@@ -147,18 +147,17 @@ def login(request,
147147
148148 # Do we have a Discovery Service?
149149 discovery_service = getattr (settings , 'SAML2_DISCO_URL' , False )
150- if discovery_service :
151- if not selected_idp and discovery_service :
152- # We have to build the URL to redirect to with all the information
153- # for the Discovery Service to know how to send the flow back to us
154- login_url = request .build_absolute_uri (reverse ('saml2_login' ))
155- login_url = '{0}?next={1}' .format (login_url ,
156- urlquote (came_from , safe = '' ))
157- ds_url = '{0}?entityID={1}&return={2}&returnIDParam=idp'
158- ds_url = ds_url .format (discovery_service ,
159- urlquote (getattr (conf ,'entityid' ), safe = '' ),
160- urlquote (login_url , safe = '' ))
161- return HttpResponseRedirect (ds_url )
150+ if discovery_service and not selected_idp :
151+ # We have to build the URL to redirect to with all the information
152+ # for the Discovery Service to know how to send the flow back to us
153+ login_url = request .build_absolute_uri (reverse ('saml2_login' ))
154+ login_url = '{0}?next={1}' .format (login_url ,
155+ urlquote (came_from , safe = '' ))
156+ ds_url = '{0}?entityID={1}&return={2}&returnIDParam=idp'
157+ ds_url = ds_url .format (discovery_service ,
158+ urlquote (getattr (conf ,'entityid' ), safe = '' ),
159+ urlquote (login_url , safe = '' ))
160+ return HttpResponseRedirect (ds_url )
162161
163162 # is a embedded wayf needed?
164163 idps = available_idps (conf )
0 commit comments