Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
restore #30 "if user attribute is callable then call it..."
  • Loading branch information
joetsoi authored Nov 28, 2016
commit 8524655dcf1a03a80483a15197c992ce73d47d8b
10 changes: 8 additions & 2 deletions djangosaml2/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,14 @@ def update_user(self, user, attributes, attribute_mapping,
try:
for attr in django_attrs:
if hasattr(user, attr):
modified = self._set_attribute(
user, attr, attributes[saml_attr][0])
user_attr = getattr(user, attr)
if callable(user_attr):
modified = user_attr(
attributes[saml_attr])
else:
modified = self._set_attribute(
user, attr, attributes[saml_attr][0])

user_modified = user_modified or modified

elif profile is not None and hasattr(profile, attr):
Expand Down