示例#1
0
def get_authorization_by_logintoken(request, logintoken):
    """Redirect for users who do have a logintoken (i.e. a hyvertysing page)
    """
    genus = get_genus()

    access_token = genus.retrieve_access_token_by_login(
        logintoken
    )

    access_token, created = UserAssociation.objects.get_or_create_from_token(
            access_token
        )

    user = authenticate(
        username=access_token.user.username,
        password=access_token.get_password())

    if not user:
        mail_admins(
            'authenticate failure for: %s ' % access_token.user.username,
            'Faulty password? or user does not exist')

    login(request, user)

    social_user_authenticated.send(
        sender=None,
        user=user,
        access_token=access_token)

    return HttpResponseRedirect(
            reverse('get_authorized') + \
                "?%s" % request.META['QUERY_STRING']
        )
示例#2
0
def get_user_authorized_redirect(
        request,
        genus=None,
        requesttoken_user=None):
    """User has authorized, so store the access token and redirect to a more
    useful page
    """
    token = requesttoken_user

    access_token = genus.retrieve_access_token(
            token,
    )

    access_token, created = UserAssociation.objects.get_or_create_from_token(
            access_token
        )

    user = authenticate(
        username=access_token.user.username,
        password=access_token.get_password())

    if not user:
        mail_admins(
            'authenticate failure for: %s ' % access_token.user.username,
            'Faulty password? or user does not exist')

    login(request, user)

    social_user_authenticated.send(
        sender=None,
        user=user,
        access_token=access_token)

    return HttpResponseRedirect(reverse('get_authorized'))