def reset_password(token): if current_user.is_authenticated: return redirect(url_for('index')) the_user = User.verify_reset_password_token(token) if not the_user: return redirect(url_for('index')) form = ResetPasswordForm() if form.validate_on_submit(): the_user.set_password(form.password.data) db.session.commit() flash('Your password has been reset.') return redirect(url_for('login')) return render_template('auth/reset_password.html', form=form)
def password_reset(token): form = ResetPasswordForm() if current_user.is_authenticated: return redirect(url_for('main.index')) elif form.validate_on_submit(): if User.reset_password(token, form.new_password.data): db.session.commit() flash('Your password has been updated.') return redirect(url_for('main.index')) else: return redirect(url_for('main.index')) return render_template('auth/reset_password.html', form=form)
def reset_password(token): if current_user.is_authenticated: return redirect(url_for("main.home")) user = User.verify_reset_password_token(token) if not user: return redirect(url_for("main.home")) form = ResetPasswordForm() if form.validate_on_submit(): user.password = pbkdf2_sha512.hash(form.password.data) db.session.commit() flash("Your password has been reset.") return redirect(url_for("auth.signin")) return render_template("reset-password.html", form=form)
def reset_password(token): # temporary removing registration flash('Registration is closed', 'danger') return redirect(url_for('auth.login')) if current_user.is_authenticated: return redirect(url_for('main.index')) user = User.verify_reset_password_token(token) if not user: return redirect(url_for('main.index')) form = ResetPasswordForm() if form.validate_on_submit(): user.set_password(form.password.data) db.session.commit() flash('Your password has been reset') return redirect(url_for('auth.login')) return render_template('auth/reset_password.html', form=form)
def reset_password(id): user = User.query.filter_by(member_id=id).first() if user is None: flash("No such user", "error") return redirect(url_for("member_details", id=id)) current_user = User.query.filter_by(id=session["user_id"]).first() if not "ADMIN" in current_user.roles() and current_user.id != user.id: flash( "You are not authorized to use this resource, please contact system administrator", "error") return redirect(request.referrer or '/') if request.method == "GET": form = ResetPasswordForm() return render_template("auth/resetpw.html", id=id, form=form) else: form = ResetPasswordForm(request.form) if not form.validate(): return render_template("auth/resetpw.html", form=form, id=id) user.password = form.password.data db.session.add(user) db.session.commit() flash("Password changed", "success") return redirect(url_for("members_index"))