code: def update_user(self, user, attributes, attribute_mapping,
                      force_save=False):
          
          if not attribute_mapping:
              return user
  
          user_modified = False
          for saml_attr, django_attrs in attribute_mapping.items():
              attr_value_list = attributes.get(saml_attr)
              if not attr_value_list:
                  logger.debug(
                      'Could not find value for "%s", not updating fields "%s"',
                      saml_attr, django_attrs)
                  continue
  
              for attr in django_attrs:
                  if hasattr(user, attr):
                      user_attr = getattr(user, attr)
                      if callable(user_attr):
                          modified = user_attr(attr_value_list)
                      else:
                          modified = self._set_attribute(user, attr, attr_value_list[0])
  
                      user_modified = user_modified or modified
                  else:
                      logger.debug(
                          'Could not find attribute "%s" on user "%s"', attr, user)
  
          logger.debug('Sending the pre_save signal')
          signal_modified = any(
              [response for receiver, response
               in pre_user_save.send_robust(sender=user.__class__,
                                            instance=user,
                                            attributes=attributes,
                                            user_modified=user_modified)]
              )
  
          if user_modified or signal_modified or force_save:
              user.save()
  
          return user
docs: Update a user with a set of attributes and returns the updated user.
  
          By default it uses a mapping defined in the settings constant
          SAML_ATTRIBUTE_MAPPING. For each attribute, if the user object has
          that field defined it will be set.