Beispiel #1
0
def signin():
    if request.method == 'GET':
        return render_template('forms/signin.html')
    
    pennkey  = request.form['pennkey']
    password = request.form['password']

    user = users.sign_in(pennkey, password)
    if user is not None:
        session['user'] = user
        return redirect(url_for('hub'))
    
    return render_template('forms/signin.html')
Beispiel #2
0
def update():
    if request.method == 'GET':
        return render_template('forms/update.html', error=None)

    pennkey = request.form['pennkey']
    password = request.form['password']
    name  = request.form['name']
    email = request.form['email']
    gradyear = request.form['gradyear']

    user = users.sign_in(pennkey, password)
    if user is not None: 
        users.update(pennkey, name=name, email=email, gradyear=gradyear)
        return redirect(url_for('hub'))

    return render_template('forms/update.html', error='password incorrect')
Beispiel #3
0
def password_reset():
    if request.method == 'GET':
        return render_template('forms/password_reset.html', error=None)

    pennkey = request.form['pennkey']
    old_password = request.form['old_password']
    password = request.form['password']
    confirm  = request.form['confirm_password']
    if not (password == confirm):
        return render_template('forms/password_reset.html', error="passwords don't match")

    user = users.sign_in(pennkey, old_password)
    if user is not None: 
        users.update(pennkey, password=password)
        return redirect(url_for('hub'))

    return render_template('forms/password_reset.html', error='old password incorrect')