@@ -230,27 +230,23 @@ def update_user(self, user, attributes, attribute_mapping,
230
230
user_modified = False
231
231
profile_modified = False
232
232
for saml_attr , django_attrs in attribute_mapping .items ():
233
- try :
234
- for attr in django_attrs :
235
- if hasattr (user , attr ):
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
-
244
- user_modified = user_modified or modified
245
-
246
- elif profile is not None and hasattr (profile , attr ):
247
- modified = self ._set_attribute (
248
- profile , attr , attributes [saml_attr ][0 ])
249
- profile_modified = profile_modified or modified
250
-
251
- except KeyError :
252
- # the saml attribute is missing
253
- pass
233
+ attr_value_list = attributes .get (saml_attr )
234
+ if not attr_value_list :
235
+ continue
236
+
237
+ for attr in django_attrs :
238
+ if hasattr (user , attr ):
239
+ user_attr = getattr (user , attr )
240
+ if callable (user_attr ):
241
+ modified = user_attr (attr_value_list )
242
+ else :
243
+ modified = self ._set_attribute (user , attr , attr_value_list [0 ])
244
+
245
+ user_modified = user_modified or modified
246
+
247
+ elif profile is not None and hasattr (profile , attr ):
248
+ modified = self ._set_attribute (profile , attr , attr_value_list [0 ])
249
+ profile_modified = profile_modified or modified
254
250
255
251
logger .debug ('Sending the pre_save signal' )
256
252
signal_modified = any (
0 commit comments