Skip to content

Commit 9aa267f

Browse files
committed
some cleanup
1 parent 8f6ecaa commit 9aa267f

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

djangosaml2/backends.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,17 @@ def _update_user(self, user, attributes, attribute_mapping, force_save=False):
215215
else:
216216
logger.debug('Could not find attribute "%s" on user "%s"', attr, user)
217217

218+
signal_modified = self.send_user_update_signal(user, attributes, user_modified)
219+
220+
if user_modified or signal_modified or force_save:
221+
user.save()
222+
logger.debug('User updated with incoming attributes')
223+
224+
return user
225+
226+
def send_user_update_signal(self, user, attributes, user_modified) -> bool:
227+
""" Send out a pre-save signal after the user has been updated with the SAML attributes.
228+
"""
218229
logger.debug('Sending the pre_save signal')
219230
signal_modified = any(
220231
[response for receiver, response
@@ -223,9 +234,4 @@ def _update_user(self, user, attributes, attribute_mapping, force_save=False):
223234
attributes=attributes,
224235
user_modified=user_modified)]
225236
)
226-
227-
if user_modified or signal_modified or force_save:
228-
user.save()
229-
logger.debug('User updated with incoming attributes')
230-
231-
return user
237+
return signal_modified

djangosaml2/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,6 @@ def fail_acs_response(request, *args, **kwargs):
7777
The default behavior uses SAML specific template that is rendered on any ACS error,
7878
but this can be simply changed so that PermissionDenied exception is raised instead.
7979
"""
80-
failure_function = import_string(get_custom_setting('SAML_ACS_FAILURE_RESPONSE_FUNCTION', 'djangosaml2.acs_failures.template_failure'))
80+
failure_function = import_string(get_custom_setting('SAML_ACS_FAILURE_RESPONSE_FUNCTION',
81+
'djangosaml2.acs_failures.template_failure'))
8182
return failure_function(request, *args, **kwargs)

0 commit comments

Comments
 (0)