def change(): form = ChangePasswordForm() if form.validate_on_submit(): current_user.set_password(form.new_pass.data) db.session.commit() flash('Password successfully changed.') return redirect(url_for('auth.change')) return render_template('auth/change.html', title='Change Password', form=form)
def changepw(): form = ChangePasswordForm() if form.validate_on_submit(): oldpw = form.old_password.data newpw = form.password.data if not current_user.verify_password(oldpw): flash("旧密码不正确", "danger") elif oldpw == newpw: flash("新密码和旧密码一致,修改无效", "warning") else: current_user.password = newpw flash("修改成功.", "success") return redirect(url_for('dashboard')) return render_template("changepw.html", form=form, user=current_user)
def change_password(): form = ChangePasswordForm() if form.validate_on_submit(): new_pw = bcrypt.generate_password_hash( form.password.data).decode('utf-8') current_user.password = new_pw db.session.commit() flash(f'You have successfully changed your password.', 'success') return redirect(url_for('account')) return render_template('change-password.html', title='Change Password', form=form)