def authenticate(self, username=None, password=None): log.debug("Attempting to authenticate drupal user %s" % (username, )) drupal_user = drupal.get_user(username) if drupal_user: try: profile = UserProfile.objects.get(username=drupal_user.name) log.debug("Drupal user already resgistered: %s" % (username, )) return None except UserProfile.DoesNotExist: if drupal.check_password(drupal_user, password): username, email, full_name = drupal.get_user_data( drupal_user) try: django_user = User(username=username[:30], email=email) profile = create_profile(django_user, username=username) profile.full_name = full_name profile.set_password(password) profile.save() return profile.user except IntegrityError: return None else: log.debug("Drupal user does not exist: %s" % (username, )) return None
def authenticate(self, username=None, password=None): log.debug("Attempting to authenticate drupal user %s" % (username,)) drupal_user = drupal.get_user(username) if drupal_user: try: profile = UserProfile.objects.get(username=drupal_user.name) log.debug("Drupal user already resgistered: %s" % (username,)) return None except UserProfile.DoesNotExist: if drupal.check_password(drupal_user, password): username, email, full_name = drupal.get_user_data( drupal_user) try: django_user = User(username=username[:30], email=email) profile = create_profile(django_user, username=username) profile.full_name = full_name profile.set_password(password) profile.save() return profile.user except IntegrityError: return None else: log.debug("Drupal user does not exist: %s" % (username,)) return None
def authenticate(self, username=None, password=None): log.debug("Attempting to authenticate drupal user %s" % (username,)) drupal_user = drupal.get_user(username) if drupal_user: try: profile = UserProfile.objects.get(username=drupal_user.name) log.debug("Drupal user resgistered already: %s" % (username,)) return None except UserProfile.DoesNotExist: if drupal.check_password(drupal_user, password): user_data = drupal.get_user_data(drupal_user) profile = UserProfile(**user_data) profile.set_password(password) profile.save() if profile.user is None: profile.create_django_user() return profile.user else: log.debug("Drupal user does not exist: %s" % (username,)) return None