def client_password_change(): form = PasswordChangeForm(request.form) c = current_user if c.password != form.password.data: return render_template("auth/passwordchange.html", client=c, form=form, error="Current password incorrect") if not form.validate(): return render_template("auth/passwordchange.html", client=current_user, form=form) c.password = form.new.data try: db.session().commit() except: db.session().rollback() raise return redirect(url_for("client_my"))
def change_password(user_id): form = PasswordChangeForm(request.form) print(form.validate()) for i in form.errors: print(form.errors[i]) if not form.validate(): return render_template("auth/user.html", user=User.query.get(user_id), form=form, collapsed=False) print(user_id) account = User.query.get(user_id) account.password = request.form.get("newpassword") print("\n\n\n") print(account.name) print(account.username) print(account.password) print("\n\n\n") db.session().commit() return render_template("auth/loginform.html", form=LoginForm(), message="Password changed. Please login again.")
def bettor_change_password(): if request.method == "GET": form = PasswordChangeForm() return render_template("auth/change_password.html", form = form) elif request.method == "POST": form = PasswordChangeForm(request.form) if not form.validate(): return render_template("auth/change_password.html", form = form) b = Bettor.query.get(current_user.id) b.password = sha256_crypt.encrypt(form.new_password.data) db.session().commit() flash("Password changed successfully!") return render_template("auth/show_user.html")
def change_password(): if request.method == "GET": return render_template("auth/changepassword.html", form=PasswordChangeForm()) form = PasswordChangeForm(request.form) if not form.validate(): return redirect(url_for("personal_space")) current_user.password = form.password.data db.session.commit() flash('Your account has been updated') return redirect(url_for("personal_space"))
def auth_profile(id): formEmail = EmailChangeForm(request.form) formPassword = PasswordChangeForm(request.form) if formEmail.submit1.data and formEmail.validate(): user = db.session.query(User).filter(User.id == id).first() user.email = formEmail.email.data db.session.commit() return redirect(url_for("auth_profileGet")) if formPassword.submit2.data and formPassword.validate(): user = db.session.query(User).filter(User.id == id).first() user.password = formPassword.password.data db.session.commit() return redirect(url_for("auth_profileGet")) return render_template("auth/profile.html", formEmail=formEmail, formPassword=formPassword)