def reset_password_post(token): email = validate_token(app.config, token) if email: user = User.objects(email=email).first() if user: form = PasswordForm(request.forms) if form.validate(): user.password = user.generate_password(form.password.data) user.save() redirect('/reset_password_success') return {'form': PasswordForm(), 'token': token} abort(404)
def reset_password_get(token): email = validate_token(app.config, token) if email: user = User.objects(email=email).first() if user: return {'form': PasswordForm(), 'token': token} abort(404)
def reset_password(token): if request.method == 'GET': email = validate_token(current_app.config, token) if email: user = User.objects(email=email).first() if user: return render_template('user/reset_password.html', form=PasswordForm(), token=token) abort(404) else: email = validate_token(current_app.config, token) if email: user = User.objects(email=email).first() if user: form = PasswordForm() if form.validate_on_submit(): user.password = user.generate_password(form.password.data) user.save() return redirect('/reset_password_success') return render_template('user/reset_password.html', form=PasswordForm(), token=token) abort(404)
def reset_password(token): if request.method == 'GET': email = validate_token(current_app.config, token) if email: user = User.objects(email=email).first() if user: return render_template('users/reset_password.html', form=PasswordForm(), token=token) abort(404) else: email = validate_token(current_app.config, token) if email: user = User.objects(email=email).first() if user: form = PasswordForm(request.form) if form.validate_on_submit(): user.password = user.generate_password(form.password.data) user.save() return redirect('/reset_password_success') return render_template('users/reset_password.html', form=PasswordForm(), token=token) abort(404)