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
def index(self, sessionKey, request): """ The user has granted permission to create a new account using the e-mail address and OpenID identity provided. Verify their unique request and display a page where they can input basic information needed to establish the account """ u = UniqueRequest() if not u.exists(sessionKey=sessionKey, requestKey='add_openid.new_account', value=request): raise cherrypy.HTTPError(400, 'Invalid request') r = cherrypy.request e = r.app.jinjaEnv dataParts = u.get_data(sessionKey=sessionKey, requestKey='add_openid.new_account').split('|') r.model['pageData']['email'] = dataParts[0] r.model['pageData']['oidIdentifier'] = dataParts[1] r.model['pageData']['sessionKey'] = sessionKey r.model['pageData']['request'] = request return e.get_template( 'html/{0}/account/add/new.html'.format( r.model['userSettings']['layout']))\ .render(model=r.model)
def confirm(self, sessionKey, request, firstName, lastName, userName, oidIdentifier, email): u = UniqueRequest() if not u.exists(sessionKey=sessionKey, requestKey='add_openid.new_account', value=request): raise cherrypy.HTTPError(400, 'Invalid request') with grab_connection('main') as conn: u.delete(connection=conn, sessionKey=sessionKey, requestKey='add_openid.new_account') id = UserAccount().create(connection=conn, params={ 'first_name': firstName, 'last_name': lastName, 'user_name': userName, 'email': email }) OpenIdAccount().create(connection=conn, userAccountId=id, oidIdentifier=oidIdentifier) SessionHelper().push('user.account_id', id) raise cherrypy.HTTPRedirect('/')
def index(self, sessionKey, request): """ The user has granted permission to associate the OpenID identifier with their existing user account. """ # Try to consume the given request u = UniqueRequest() if not u.exists(sessionKey=sessionKey, requestKey='add_openid.existing_account', value=request): raise cherrypy.HTTPError(400, 'Invalid request') dataParts = u.get_data(sessionKey=sessionKey, requestKey='add_openid.existing_account').split('|') id = int(dataParts[0]) with grab_connection('main') as conn: u.delete(connection=conn, sessionKey=sessionKey, requestKey='add_openid.existing_account') OpenIdAccount().create(connection=conn, userAccountId=id, oidIdentifier=dataParts[1]) SessionHelper().push('user.account_id', id) raise cherrypy.HTTPRedirect('/')