def login(self, session, message='', first_name='', last_name='', email='', zip_code='', original_location=None): original_location = create_valid_user_supplied_redirect_url(original_location, default_url='index') if first_name or last_name or email or zip_code: try: attendee = session.lookup_attendee(first_name.strip(), last_name.strip(), email, zip_code) if not attendee.staffing: message = safe_string( 'You are not signed up as a volunteer. ' '<a href="volunteer?id={}">Click Here</a> to sign up.'.format(attendee.id)) elif not attendee.dept_memberships and not c.AT_THE_CON: message = 'You have not been assigned to any departments; ' \ 'an admin must assign you to a department before you can log in' except Exception: message = 'No attendee matches that name and email address and zip code' if not message: ensure_csrf_token_exists() cherrypy.session['staffer_id'] = attendee.id raise HTTPRedirect(original_location) return { 'message': message, 'first_name': first_name, 'last_name': last_name, 'email': email, 'zip_code': zip_code, 'original_location': original_location }
def login(self, session, message='', original_location=None, **params): original_location = create_valid_user_supplied_redirect_url(original_location, default_url='homepage') if 'email' in params: try: account = session.get_account_by_email(params['email']) if not valid_password(params['password'], account): message = 'Incorrect password' except NoResultFound: message = 'No account exists for that email address' if not message: cherrypy.session['account_id'] = account.id ensure_csrf_token_exists() raise HTTPRedirect(original_location) return { 'message': message, 'email': params.get('email', ''), 'original_location': original_location, }
def csrf_token(): ensure_csrf_token_exists() return safe_string( '<input type="hidden" name="csrf_token" value="{}" />'.format( cherrypy.session["csrf_token"]))
def csrf_token(): ensure_csrf_token_exists() return safe_string('<input type="hidden" name="csrf_token" value="{}" />'.format(cherrypy.session["csrf_token"]))