Ejemplo n.º 1
0
    def index(self, openid):
        """
        .. note:: An OpenID Identifier must be present in the user's session data.
        """
        r = cherrypy.request
        s = SessionHelper()
        k = 'account_create.openid_identity_url'
        if not s.has_key(k):
            raise cherrypy.HTTPError(400, message='Missing OpenID identity')
            
        # Permanently consume the account creation identity url to prevent the
        # user from accidentally re-accessing the page after the process has
        # completed.  Also avoid malicious usage.
        id = s.pop(k)
        cherrypy.log.error('Consuming id {0}'.format(id), 'AccountController.create')

        env = r.app.jinjaEnv
        template = env.get_template('html/{0}/account/create.html'.format(r.model['userSettings']['layout']))
        return template.render(
            model=r.model,
            oidIdentifier=id)
Ejemplo n.º 2
0
 def __on_success(cls, identity_url):
     """
     The user has successfully authenticated via an OpenID provider.  Now we
     have to determine whether their identity URL is associated with an
     existing site account.  If so, then we route the request to the post-
     login URL, if possible, or to the homepage.  If the identity URL is not
     associated with an existing account, then we route the request to a page
     where we give the user an opportunity to establish a new site account
     by providing some very basic information (e.g. e-mail address).
     """
     s = SessionHelper()
     accountId = OpenIdAccount().get_account_id(identity_url)
     if accountId is None:
         # Publish the OpenID identity url to be used for account creation.
         # The account creation controller will pop it from the session data
         s.push('account_create.openid_identity_url', identity_url)
         raise cherrypy.HTTPRedirect('/account/create')
     else:
         s.push('user.account_id', accountId)
         raise cherrypy.HTTPRedirect('/' if not s.has_key('user.post_login_return_to') \
             else s.peek('user.post_login_return_to'))