Skip to content

Commit 8524655

Browse files
authored
restore #30 "if user attribute is callable then call it..."
1 parent 33f8309 commit 8524655

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

djangosaml2/backends.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,14 @@ def update_user(self, user, attributes, attribute_mapping,
233233
try:
234234
for attr in django_attrs:
235235
if hasattr(user, attr):
236-
modified = self._set_attribute(
237-
user, attr, attributes[saml_attr][0])
236+
user_attr = getattr(user, attr)
237+
if callable(user_attr):
238+
modified = user_attr(
239+
attributes[saml_attr])
240+
else:
241+
modified = self._set_attribute(
242+
user, attr, attributes[saml_attr][0])
243+
238244
user_modified = user_modified or modified
239245

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

0 commit comments

Comments
 (0)