Exemplo n.º 1
0
def ident_show(request, userid, direct=False):
    """Show identity
    """
    result = {}
    # Try to get object, and propose to create if
    # not annonymous else 404
    try:
        ident = Identity.objects.get(userid=userid)
    except Identity.DoesNotExist:
        if request.user.is_authenticated() and not direct:
            result['userid'] = userid
            return render_to_response('account/identities/blank.html', result, context_instance=RequestContext(request))
        else:
            raise Http404

    if not ident.is_active:
        raise Http404

    if direct:
        result['server_url'] = getViewURL(request, 'endpoint')
    result['ident'] = ident
    result['identperms'] = IdentityPerms.objects.get(identity=ident)
    result['useridurl'] = getViewURL(request, 'ident', kwargs={'userid':userid})

    if ident.userprofile.user == request.user:
        result['mine'] = True
        result['assocs'] = TrustedConsumers.objects.filter(identity=ident, user=request.user, always=True)
    return render_to_response('account/identities/show.html', result, context_instance=RequestContext(request))
Exemplo n.º 2
0
def idPage(request):
    """HomePage :
    If authenticated : redirect to account page
    Else : subscribe form
    """
    if request.user:
        if request.user.is_authenticated():
            return HttpResponseRedirect(reverse("accountdetail"))
    form = SubscribeWizard([SubscribeForm, UsernameForm]).get_form(0)
    return render_to_response('account/home.html', {'server_url': getViewURL(request, 'endpoint'),
        'server_xrds_url': getViewURL(request, "idpXrds"), 'form' : form},
        context_instance=RequestContext(request))
Exemplo n.º 3
0
 def setUp(self):
     self.id_select = "http://specs.openid.net/auth/2.0/identifier_select"
     self.generate_requests(self.id_select)
     # some ids
     userid = "dummy"
     self.id_slash = util.getViewURL(self.request, 'ident', kwargs={'userid' : userid})
     self.id_noslash = self.id_slash.rstrip("/")
Exemplo n.º 4
0
    def test_unreachableRealm(self):
        self.request = dummyRequest()

        id_url = util.getViewURL(self.request, "home")

        # Set up the OpenID request we're responding to.
        op_endpoint = 'http://127.0.0.1:8080/endpoint'
        message = Message.fromPostArgs({
            'openid.mode': 'checkid_setup',
            'openid.identity': id_url,
            'openid.return_to': 'http://unreachable.invalid/%s' % (self.id(),),
            'openid.sreg.required': 'postcode',
            })
        self.openid_request = CheckIDRequest.fromMessage(message, op_endpoint)

        util.setRequest(self.request, self.openid_request)

        response = views.showDecidePage(self.request, self.openid_request)
        self.failUnless('trust_root_valid is Unreachable' in response.content,
                        response)