예제 #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 __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'))
         
예제 #3
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');