Пример #1
0
 def _create_email_exists_message(self, email, oidIdentifier):
     c = cherrypy.request.app.config
     env = cherrypy.request.app.jinjaEnv
     s = SessionHelper()
     u = UniqueRequest()
     
     value = u.create(
         sessionKey=cherrypy.session.id,
         requestKey='add_openid.existing_account',
         data='|'.join([str(UserAccount().id_from_email(email)), oidIdentifier]))
     s.push('add_openid.existing_account', value)
         
     # need to pass the session id in case they visit it using a different browser
     linkAddress = 'http://{0}/account/add/email?sessionKey={1}&request={2}'.format(
         make_netloc(),
         cherrypy.session.id,
         s.peek('add_openid.existing_account'))
     
     text = env.get_template('email/account/create/existing/verify.txt').render(
         siteName=c['appSettings']['siteName'],
         email=email,
         identityURL=oidIdentifier,
         linkAddress=linkAddress)
     
     msg = MIMEText(text)
     msg['Subject'] = '{0} - Confirm Add E-mail Address'.format(c['appSettings']['siteName'])
     msg['From'] = self._get_from_address()
     msg['To'] = email
     
     return msg
Пример #2
0
 def __get_all_user_items(self):
     s = SessionHelper()
     return {
         'userItemsAll': get_all_rows_nc(
             'main',
             'select item_id, title from items where ref_user_account_id = %(i)s',
             { 'i': s.peek('user.account_id') })
     }
Пример #3
0
 def user_has_draft_item(cls, id):
     s = SessionHelper()
     return get_scalar_nc(
         'main',
         """
         select exists (select 0 from draft_items
         where ref_user_account_id = %(i)s) as a
         """,
         { 'i': s.peek('user.account_id') },
         'a')
Пример #4
0
 def create_user_draft_item(cls, id):
     """
     Create a new item record and return its item id
     """
     s = SessionHelper()
     execute_action_nc(
         'main',
         """
         insert into draft_items (ref_user_account_id) values (%(i)s)
         """,
         { 'i': s.peek('user.account_id') })
     
Пример #5
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)
Пример #6
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'))
         
Пример #7
0
 def check(self, returnTo):
     cherrypy.log.error('inside check', 'RequireLogin')
     s = SessionHelper()
     if s.peek('user.account_id') is None:
         s.push('user.post_login_return_to', returnTo)
         raise cherrypy.HTTPRedirect('/error/login-required');