def account_details(account_id): a = Coach.query.get(account_id) if request.method == "POST": form = ChangePasswordForm(request.form) a.update_password(account_id=account_id, password=form.password.data) return render_template("auth/details.html", account=a, form=ChangePasswordForm())
def change_password(): form = ChangePasswordForm() if form.validate_on_submit(): if current_user.verify_password(form.old_password.data): current_user.password = form.password.data db.session.add(current_user) flash('Your password has been updated.') return redirect(url_for('main.index')) else: flash('Invalid password.') return render_template("auth/change_password.html", form=form)
def auth_change_password(): form = ChangePasswordForm(request.form) if not form.validate(): return render_template("auth/change_password.html", form=form) hashed_password = bcrypt.generate_password_hash( form.newPassword.data).decode('utf-8') account = User.query.filter_by(id=current_user.id).first() account.password = hashed_password db.session.commit() return render_template("auth/change_password.html", form=ChangePasswordForm())
def change_password(): form = ChangePasswordForm() if form.validate_on_submit(): if current_user.verify_password(form.old_password.data): if safe_str_cmp(form.old_password.data, form.new_password.data): flash('Cannot use old password.') return render_template("auth/change_password.html", form=form) 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.') return redirect(url_for('main.index')) flash('Incorrect password.') return render_template("auth/change_password.html", form=form)
def auth_change_password(): dbUser = User.query.get(current_user.id) if request.method == "GET": form = ChangePasswordForm() form.password.data = dbUser.password form.confirm.data = dbUser.password return render_template("auth/changePassword.html", form=form) form = ChangePasswordForm(request.form) if not form.validate(): return render_template("auth/changePassword.html", form=form) dbUser.password = form.password.data db.session().commit() return redirect(url_for("auth_userinfo"))
def changePassword(): username = current_user.username form = ChangePasswordForm(request.form) if not form.validate(): amount = Item.amount_of_items_by_userid(current_user.id) return render_template("auth/userprofile.html", user=user, amount=amount, form=form, username=username) u = User.query.get(current_user.id) u.password = form.password.data db.session().commit() return redirect(url_for("items_index"))
def change_password(): if request.method == "GET": return render_template("/auth/changepassword.html", form = ChangePasswordForm()) form = ChangePasswordForm(request.form) user = User.query.get(current_user.id) if not form.validate_on_submit(): return render_template("/auth/changepassword.html", form = form) if not bcrypt.check_password_hash(user.password, form.old_password.data): return render_template("/auth/changepassword.html", form = form, error = "Incorrect old password. Please check that you give correct old password") user.password = bcrypt.generate_password_hash(form.new_password.data).decode('utf-8') db.session().commit() return redirect(url_for("index"))
def user(username): user = User.query.filter_by(username=username).first_or_404() if current_user.id != user.id: return render_template("index.html", msg=msg_other_user) form = ChangePasswordForm() amount = Item.amount_of_items_by_userid(current_user.id) return render_template("auth/userprofile.html", user=user, amount=amount, form=form, username=username)
def auth_change_password_form(): return render_template("auth/change_password.html", form=ChangePasswordForm())