def register(): app.logger.info("Registration") error = None if request.method == 'POST': user_email = request.form['email'].lower() user_name = request.form['name'] if not util.check_valid_user(user_email): util.create_user(user_email, user_name) flash('New User created and logged in.') set_session_data(session, {U.EMAIL: user_email, U.NAME: user_name}) return redirect(url_for('make_decision')) else: error = "User account Already created" return render_template('register.html', error=error)
def login(): app.logger.info("in login") error = None if request.method == 'POST': user_email = request.form['email'].lower() if util.check_valid_user(user_email): user = util.get_user(user_email=user_email) set_session_data(session, user) if user[U.FREEZE_ACCOUNT]: flash('Account Frozen') return redirect(url_for('login')) flash('You were logged in') return redirect(url_for('make_decision')) else: flash('User not registered. Please register.') return redirect(url_for('register')) return render_template('login.html', error=error)