Exemple #1
0
    def authenticate(self, **kwargs):
        """Authenticate the user based on an OpenID response."""
        # Require that the OpenID response be passed in as a keyword
        # argument, to make sure we don't match the username/password
        # calling conventions of authenticate.

        openid_response = kwargs.get('openid_response')
        if openid_response is None:
            return None

        if openid_response.status != SUCCESS:
            return None

        user = None
        try:
            user_openid = UserOpenID.objects.get(
                claimed_id__exact=openid_response.identity_url)
            log.debug("Drupal openid user resgistered already: %s" % (openid_response.identity_url,))
            return None
        except UserOpenID.DoesNotExist:
            drupal_user = drupal.get_openid_user(openid_response.identity_url)
            if drupal_user:
                user_data = drupal.get_user_data(drupal_user)
                profile = UserProfile(**user_data)
                profile.save()
                if profile.user is None:
                    profile.create_django_user()
                self.associate_openid(profile.user, openid_response)
                return profile.user
Exemple #2
0
    def authenticate(self, **kwargs):
        """Authenticate the user based on an OpenID response."""
        # Require that the OpenID response be passed in as a keyword
        # argument, to make sure we don't match the username/password
        # calling conventions of authenticate.

        openid_response = kwargs.get('openid_response')
        if openid_response is None:
            return None

        if openid_response.status != SUCCESS:
            return None
        msg = 'Attempting to authenticate drupal user %s'
        log.debug(msg % openid_response.identity_url)

        try:
            UserOpenID.objects.get(
                claimed_id__exact=openid_response.identity_url)
            msg = 'Drupal openid user resgistered already: %s'
            log.debug(msg % openid_response.identity_url)
            return None
        except UserOpenID.DoesNotExist:
            drupal_user = drupal.get_openid_user(openid_response.identity_url)
            if drupal_user:
                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.save()
                    self.associate_openid(django_user, openid_response)
                    return django_user
                except IntegrityError:
                    return None
        return None
Exemple #3
0
    def authenticate(self, **kwargs):
        """Authenticate the user based on an OpenID response."""
        # Require that the OpenID response be passed in as a keyword
        # argument, to make sure we don't match the username/password
        # calling conventions of authenticate.

        openid_response = kwargs.get('openid_response')
        if openid_response is None:
            return None

        if openid_response.status != SUCCESS:
            return None
        msg = 'Attempting to authenticate drupal user %s'
        log.debug(msg % openid_response.identity_url)

        try:
            UserOpenID.objects.get(
                claimed_id__exact=openid_response.identity_url)
            msg = 'Drupal openid user resgistered already: %s'
            log.debug(msg % openid_response.identity_url)
            return None
        except UserOpenID.DoesNotExist:
            drupal_user = drupal.get_openid_user(openid_response.identity_url)
            if drupal_user:
                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.save()
                    self.associate_openid(django_user, openid_response)
                    return django_user
                except IntegrityError:
                    return None
        return None