Ejemplo n.º 1
0
def login():
    if request.method == 'POST':
        email = request.form['email']
        password = request.form['password']

        try:
            if User.is_login_valid(email, password):
                session['email'] = email
                return redirect(url_for('.index'))
        except UserErrors.UserError as e:
            flash("Your login info was incorrect!", 'danger')

    return render_template('login.html')
Ejemplo n.º 2
0
def deregister():
    if request.method == 'POST':
        email = session['email']
        password = request.form['password']
        try:
            if User.is_login_valid(email, password):
                User.deregister(email)
                session['email'] = None
                flash("Your account has been removed!", 'warning')
                return render_template('home.html')
        except UserErrors.UserError as e:
            flash("Your password was incorrect", 'danger')

    return render_template('deregister.html', email=session['email'])