Skip to content

Commit 2166396

Browse files
authored
Fix for overriding custom error view using SAML_ACS_FAILURE_RESPONSE_FUNCTION (#247)
* Fix SAML_ACS_FAILURE_RESPONSE_FUNCTION override: Add the `import_string` import so that you can use the above variable to supply a different template rendering function. * Update Custom Error Handler docs: The custom error function that is passed in using SAML_ACS_FAILURE_RESPONSE_FUNCTION has changed signature and the example no longer works. The custom function with an extra positional argument so the documentation has been updated to include this.
1 parent 033b16c commit 2166396

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,9 @@ This should be a view which takes a request, optional exception which occured
388388
and status code, and returns a response to serve the user. E.g. The default
389389
implementation looks like this::
390390

391-
def template_failure(request, exception=None, **kwargs):
391+
def template_failure(request, exception=None, status=403, **kwargs):
392392
""" Renders a simple template with an error message. """
393-
return render(request, 'djangosaml2/login_error.html', {'exception': exception}, status=kwargs.get('status', 403))
393+
return render(request, 'djangosaml2/login_error.html', {'exception': exception}, status=status)
394394

395395

396396
User attributes

djangosaml2/views.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from django.utils.decorators import method_decorator
2929
from django.views.decorators.csrf import csrf_exempt
3030
from django.views.generic import View
31+
from django.utils.module_loading import import_string
3132
from saml2 import BINDING_HTTP_POST, BINDING_HTTP_REDIRECT
3233
from saml2.client_base import LogoutError
3334
from saml2.config import SPConfig

0 commit comments

Comments
 (0)