|
|
|
@ -2,7 +2,7 @@ import flask_login as fl
|
|
|
|
|
from flask import Blueprint, flash, redirect, render_template, request, url_for, current_app
|
|
|
|
|
|
|
|
|
|
from yadc import db
|
|
|
|
|
from yadc.forms import LoginForm, RegisterForm, ResetPasswordForm
|
|
|
|
|
from yadc.forms import LoginForm, RegisterForm, ResetPasswordForm, ResetPasswordPassForm
|
|
|
|
|
from yadc.models import User
|
|
|
|
|
from yadc.utils import nextpage, flasherrors
|
|
|
|
|
|
|
|
|
@ -43,22 +43,24 @@ def reset_password():
|
|
|
|
|
if fl.current_user.is_authenticated:
|
|
|
|
|
return redirect(url_for('main.index'))
|
|
|
|
|
|
|
|
|
|
form = ResetPasswordPassForm(request.form)
|
|
|
|
|
if request.method == 'POST' and form.validate():
|
|
|
|
|
flash('Password successfully reset.') # for real
|
|
|
|
|
return redirect(url_for('.login'))
|
|
|
|
|
|
|
|
|
|
form = ResetPasswordForm(request.form)
|
|
|
|
|
if request.method == 'POST' and form.validate():
|
|
|
|
|
user = User.query.filter_by(email=form.email.data).first()
|
|
|
|
|
|
|
|
|
|
if user:
|
|
|
|
|
user.create_password('kuxaman')
|
|
|
|
|
db.session.commit()
|
|
|
|
|
#do something to reset the password
|
|
|
|
|
return render_template('auth/reset_password.html', form=ResetPasswordPassForm(request.form))
|
|
|
|
|
|
|
|
|
|
flash('Password successfully reset. Check your email.')
|
|
|
|
|
flash('Password successfully reset.') # faked
|
|
|
|
|
return redirect(url_for('.login'))
|
|
|
|
|
|
|
|
|
|
flasherrors(form)
|
|
|
|
|
return render_template('auth/reset_password.html', form=form)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route('/register', methods=['GET', 'POST'])
|
|
|
|
|
def register():
|
|
|
|
|
if fl.current_user.is_authenticated:
|
|
|
|
|