Ejemplo n.º 1
0
def change_email():
    success = False
    if request.method == 'POST' and request.form['email']:
        user = database.update_user(username=current_user.username, email=request.form['email'])
        success = True
        user = database.get_user(username=current_user.username)
        if user is not None:
            login_user(user)
    return render_template("accounts/change_email.html", success=success)
Ejemplo n.º 2
0
def change_email():
    success = False
    if request.method == 'POST' and request.form['email']:
        user = database.update_user(username=current_user.username,
                                    email=request.form['email'])
        success = True
        user = database.get_user(username=current_user.username)
        if user is not None:
            login_user(user)
    return render_template("accounts/change_email.html", success=success)
Ejemplo n.º 3
0
def login():
    form = LoginForm()
    error = False
    if request.method == 'POST' and form.validate():
        m = hashlib.md5()
        m.update(form.password.data)
        user = database.get_user(username=form.username.data, password=m.hexdigest())
        if user is not None:
            login_user(user)
            return redirect(request.args.get("next") or url_for("index"))
        else:
            error=True
    return render_template("accounts/login.html", form=form, error=error)
Ejemplo n.º 4
0
def change_pass():
    form = ChangePassForm()
    error = False
    if request.method == 'POST' and form.validate():
        m = hashlib.md5()
        m.update(form.old_password.data)
        user = database.get_user(username=current_user.username, password=m.hexdigest())
        if user is not None:
            m = hashlib.md5()
            m.update(form.password.data)
            user = database.update_user(username=current_user.username, password=m.hexdigest())
            return redirect(url_for("change_pass_success"))
        error = True
    return render_template("accounts/password_change_form.html", form=form, error=error)
Ejemplo n.º 5
0
def login():
    form = LoginForm()
    error = False
    if request.method == 'POST' and form.validate():
        m = hashlib.md5()
        m.update(form.password.data)
        user = database.get_user(username=form.username.data,
                                 password=m.hexdigest())
        if user is not None:
            login_user(user)
            return redirect(request.args.get("next") or url_for("index"))
        else:
            error = True
    return render_template("accounts/login.html", form=form, error=error)
Ejemplo n.º 6
0
def change_pass():
    form = ChangePassForm()
    error = False
    if request.method == 'POST' and form.validate():
        m = hashlib.md5()
        m.update(form.old_password.data)
        user = database.get_user(username=current_user.username,
                                 password=m.hexdigest())
        if user is not None:
            m = hashlib.md5()
            m.update(form.password.data)
            user = database.update_user(username=current_user.username,
                                        password=m.hexdigest())
            return redirect(url_for("change_pass_success"))
        error = True
    return render_template("accounts/password_change_form.html",
                           form=form,
                           error=error)
Ejemplo n.º 7
0
def load_user(user_id):
    return database.get_user(user_id)
Ejemplo n.º 8
0
def validate_user(form, field):
    if (field.data and not database.get_user(field.data)):
        raise validators.ValidationError('No such Username Exists')
Ejemplo n.º 9
0
def load_user(user_id):
    return database.get_user(user_id)
Ejemplo n.º 10
0
def validate_user(form, field):
    if (field.data and not database.get_user(field.data)):
        raise validators.ValidationError('No such Username Exists')