Example #1
0
def login_user():
    user_email = request.form['email']
    user_password = request.form['password']

    if User.check_login(user_email, user_password):
        session['email'] = user_email
        return redirect(url_for('index'))
    else:
        return redirect(url_for('login_page', error_message="Your username or password was incorrect."))
Example #2
0
def login_user():
    user_email = request.form['email']
    user_password = request.form['password']

    if User.check_login(user_email, user_password):
        session['email'] = user_email
        return redirect(url_for('index'))
    else:
        return redirect(
            url_for('login_page',
                    error_message="Your username or password was incorrect."))
Example #3
0
def edit_profile():
    if User.check_login(session['email'], request.form['password']):
        user = User.find_by_email(session['email'])
        user.data.update(firstname=request.form['firstname'], lastname=request.form['lastname'],
                         university=request.form['university'], level=request.form['level'],
                         country=request.form['country'], school=request.form['college'],
                         subject=request.form['course'], year=request.form['yearofstudy'])

        user.save_to_db()
        return make_response(view_profile())
    else:
        return render_template('user-profile.html', message="Incorrect Password")
Example #4
0
def admin_update_user_profile():
    if User.check_login(session['email'], request.form['password']):
        user = User.find_by_email(request.form['email'])
        user.data.update(firstname=request.form['firstname'], lastname=request.form['lastname'],
                         university=request.form['university'], level=request.form['level'],
                         country=request.form['country'], school=request.form['college'],
                         subject=request.form['course'], year=request.form['yearofstudy'],
                         permissions=request.form['permissions'])

        user.save_to_db()
        return redirect("/admin/view-profile/" + request.form['email'])
    else:
        return render_template('user-profile.html', message="Incorrect Password")
Example #5
0
def edit_profile():
    if User.check_login(session['email'], request.form['password']):
        user = User.find_by_email(session['email'])
        user.data.update(firstname=request.form['firstname'],
                         lastname=request.form['lastname'],
                         university=request.form['university'],
                         level=request.form['level'],
                         country=request.form['country'],
                         school=request.form['college'],
                         subject=request.form['course'],
                         year=request.form['yearofstudy'])

        user.save_to_db()
        return make_response(view_profile())
    else:
        return render_template('user-profile.html',
                               message="Incorrect Password")
Example #6
0
def admin_update_user_profile():
    if User.check_login(session['email'], request.form['password']):
        user = User.find_by_email(request.form['email'])
        user.data.update(firstname=request.form['firstname'],
                         lastname=request.form['lastname'],
                         university=request.form['university'],
                         level=request.form['level'],
                         country=request.form['country'],
                         school=request.form['college'],
                         subject=request.form['course'],
                         year=request.form['yearofstudy'],
                         permissions=request.form['permissions'])

        user.save_to_db()
        return redirect("/admin/view-profile/" + request.form['email'])
    else:
        return render_template('user-profile.html',
                               message="Incorrect Password")
Example #7
0
def check_password():
    json = request.get_json()
    password = json['password']
    if User.check_login(session['email'], password):
        return jsonify({"message": "OK"}), 201
    return jsonify({"error": "Password is incorrect"}), 201
Example #8
0
def check_password():
    json = request.get_json()
    password = json['password']
    if User.check_login(session['email'], password):
        return jsonify({"message": "OK"}), 201
    return jsonify({"error": "Password is incorrect"}), 201