Beispiel #1
0
def change_password():
    """Change an existing user's password."""
    form = ChangePasswordForm()
    if form.validate_on_submit():
        if db_service.verify_password(current_user, form.old_password.data):
            current_user.password = form.new_password.data
            db_service.update_user_data(current_user)
            flash('Your password has been updated.', 'form-success')
            return redirect(url_for('main.index'))
        else:
            flash('Original password is invalid.', 'form-error')
    return render_template('account/manage.html', form=form)
Beispiel #2
0
def change_password():
    """Change an existing user's password."""
    form = ChangePasswordForm()
    if form.validate_on_submit():
        if current_user.verify_password(form.old_password.data):
            current_user.password = form.new_password.data
            db.session.add(current_user)
            db.session.commit()
            flash("Your password has been updated.", "form-success")
            return redirect(url_for("main.index"))
        else:
            flash("Original password is invalid.", "form-error")
    return render_template("account/manage.html", form=form)