Skip to content

Commit 3ec47bf

Browse files
authored
Merge pull request #200 from daggaz/master
re #199 - Always save newly created users
2 parents 1939d04 + 95e8f35 commit 3ec47bf

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

djangosaml2/backends.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,14 @@ def _update_user(self, user, attributes, attribute_mapping, force_save=False):
144144
SAML_ATTRIBUTE_MAPPING. For each attribute, if the user object has
145145
that field defined it will be set.
146146
"""
147+
# Always save a brand new user instance
148+
user_modified = user.pk is None
149+
147150
if not attribute_mapping:
151+
if user_modified:
152+
user.save()
148153
return user
149154

150-
user_modified = False
151155
for saml_attr, django_attrs in attribute_mapping.items():
152156
attr_value_list = attributes.get(saml_attr)
153157
if not attr_value_list:

0 commit comments

Comments
 (0)