1818from django .conf import settings
1919from django .contrib import auth
2020from django .contrib .auth .backends import ModelBackend
21- from django .core .exceptions import ObjectDoesNotExist , MultipleObjectsReturned , \
22- ImproperlyConfigured
21+ from django .core .exceptions import (
22+ MultipleObjectsReturned , ImproperlyConfigured ,
23+ )
2324
2425from djangosaml2 .signals import pre_user_save
2526
26- try :
27- from django .contrib .auth .models import SiteProfileNotAvailable
28- except ImportError :
29- class SiteProfileNotAvailable (Exception ):
30- pass
31-
3227
3328logger = logging .getLogger ('djangosaml2' )
3429
@@ -211,24 +206,12 @@ def update_user(self, user, attributes, attribute_mapping,
211206
212207 By default it uses a mapping defined in the settings constant
213208 SAML_ATTRIBUTE_MAPPING. For each attribute, if the user object has
214- that field defined it will be set, otherwise it will try to set
215- it in the profile object.
209+ that field defined it will be set.
216210 """
217211 if not attribute_mapping :
218212 return user
219213
220- try :
221- profile = user .get_profile ()
222- except ObjectDoesNotExist :
223- profile = None
224- except SiteProfileNotAvailable :
225- profile = None
226- # Django 1.5 custom model assumed
227- except AttributeError :
228- profile = user
229-
230214 user_modified = False
231- profile_modified = False
232215 for saml_attr , django_attrs in attribute_mapping .items ():
233216 attr_value_list = attributes .get (saml_attr )
234217 if not attr_value_list :
@@ -244,10 +227,6 @@ def update_user(self, user, attributes, attribute_mapping,
244227
245228 user_modified = user_modified or modified
246229
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
250-
251230 logger .debug ('Sending the pre_save signal' )
252231 signal_modified = any (
253232 [response for receiver , response
@@ -260,10 +239,6 @@ def update_user(self, user, attributes, attribute_mapping,
260239 if user_modified or signal_modified or force_save :
261240 user .save ()
262241
263- if (profile is not None
264- and (profile_modified or signal_modified or force_save )):
265- profile .save ()
266-
267242 return user
268243
269244 def _set_attribute (self , obj , attr , value ):
0 commit comments