Ejemplo n.º 1
0
def idplogin():
    """Does the login via OpenID.  Has to call into `oid.try_login`
    to start the OpenID machinery.
    """
    # log('%s:%d:login g.user = %s' % (__file__,__LINE__(),g.user) )
    di.d3('login g.user = %s' % (g.user) )
    # if we are already logged in, go back to were we came from
    if g.user is not None:
        return redirect(oid.get_next_url())
    if request.method == 'POST':
        openid = request.form.get('openid')
        source = request.form.get('source')
        # log('%s:%d:login with open ID "%s", source = "%s"' % (__file__,__LINE__(),openid, source))
        di.d3('login with open ID "%s", source = "%s"' % (openid, source))
        if openid:
            pape_req = pape.Request([])
            return oid.try_login(openid, ask_for=['email', 'nickname'],
                                         ask_for_optional=['fullname','dob'],
                                         extensions=[pape_req])
        if source:
            #openid = sources[source]
            openid = ei_dict[source]['discovery-url']
            #print >> sys.stderr, 'source = %s, openid = %s' % ( source, openid )
            # log('%s:%d:login with open ID "%s", source = "%s"' % (__file__,__LINE__(),openid, source))
            di.d3('login with open ID "%s", source = "%s"' % (openid, source))
            pape_req = pape.Request([])
            return oid.try_login(openid, ask_for=['email', 'nickname'],
                                         ask_for_optional=['fullname','dob'],
                                         extensions=[pape_req])
    return render_template('cpslogin.html', next=oid.get_next_url(),
                           error=oid.fetch_error(), items=ei_dict)
    """The following strings can be used in the ask_for and 
Ejemplo n.º 2
0
def Xidplogin():
    log("%s:%d:Gotcha: /idplogin" % (__file__,__LINE__() ))
    #log( pprint.pformat ( request.environ['wsgi.errors'] ) )
    res = "<html><head><title>Success</title></head><body>IDP-test geslaagd</body></html>"
    #global oid
    try:
#        from cpsdirector import app
#        oid = OpenID(app, safe_roots=[], extension_responses=[pape.Response])
        log("%s:%d:next = %s" % (__file__,__LINE__(), oid.get_next_url() ) )
        log("%s:%d:ei_dict = %s" % (__file__,__LINE__(),  pprint.pformat(ei_dict) ) )
        #res = render_template('cpslogin.html', items=ei_dict, next='blah', error='foutje')
        res = render_template('cpslogin.html', next=oid.get_next_url(), error=oid.fetch_error(), items=ei_dict)
    except BuildError as error:
        log ("%s:%d:error = %s" % (__file__,__LINE__(), error) )
        res = "<html><head><title>Failure</title></head><body>IDP-test mislukt:<br> BuildError: %s </body></html>" % error
    return build_response( res )