@@ -246,15 +246,16 @@ def get(self, request, *args, **kwargs):
246246 sso_kwargs ['nsprefix' ] = get_namespace_prefixes ()
247247
248248 logger .debug (f'Redirecting user to the IdP via { binding } binding.' )
249+ _msg = 'Unable to know which IdP to use'
249250 if binding == saml2 .BINDING_HTTP_REDIRECT :
250251 try :
251252 session_id , result = client .prepare_for_authenticate (
252253 entityid = selected_idp , relay_state = next_path ,
253254 binding = binding , sign = sign_requests ,
254255 ** sso_kwargs )
255256 except TypeError as e :
256- logger .error ('Unable to know which IdP to use ' )
257- return HttpResponse (str ( e ) )
257+ logger .error (f' { _msg } : { e } ' )
258+ return HttpResponse (_msg )
258259 else :
259260 http_response = HttpResponseRedirect (get_location (result ))
260261 elif binding == saml2 .BINDING_HTTP_POST :
@@ -263,8 +264,8 @@ def get(self, request, *args, **kwargs):
263264 try :
264265 location = client .sso_location (selected_idp , binding )
265266 except TypeError as e :
266- logger .error ('Unable to know which IdP to use ' )
267- return HttpResponse (str ( e ) )
267+ logger .error (f' { _msg } : { e } ' )
268+ return HttpResponse (_msg )
268269 session_id , request_xml = client .create_authn_request (
269270 location ,
270271 binding = binding ,
@@ -293,8 +294,9 @@ def get(self, request, *args, **kwargs):
293294 entityid = selected_idp , relay_state = next_path ,
294295 binding = binding )
295296 except TypeError as e :
296- logger .error ('Unable to know which IdP to use' )
297- return HttpResponse (str (e ))
297+ _msg = f"Can't prepare the authentication for { selected_idp } "
298+ logger .error (f'{ _msg } : { e } ' )
299+ return HttpResponse (_msg )
298300 else :
299301 http_response = HttpResponse (result ['data' ])
300302 else :
0 commit comments