|
@ -4,7 +4,7 @@ from . import auth |
|
|
from .. import db |
|
|
from .. import db |
|
|
from ..models import User |
|
|
from ..models import User |
|
|
from ..email import send_email |
|
|
from ..email import send_email |
|
|
from .forms import LoginForm, RegistrationForm |
|
|
|
|
|
|
|
|
from .forms import LoginForm, RegistrationForm, ChangePasswordForm |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@auth.before_app_request |
|
|
@auth.before_app_request |
|
@ -84,3 +84,19 @@ def resend_confirmation(): |
|
|
'auth/email/confirm', user=current_user, token=token) |
|
|
'auth/email/confirm', user=current_user, token=token) |
|
|
flash('A new confirmation email has been sent to you by email.') |
|
|
flash('A new confirmation email has been sent to you by email.') |
|
|
return redirect(url_for('main.index')) |
|
|
return redirect(url_for('main.index')) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@auth.route('/change-password', methods=['GET', 'POST']) |
|
|
|
|
|
@login_required |
|
|
|
|
|
def change_password(): |
|
|
|
|
|
form = ChangePasswordForm() |
|
|
|
|
|
if form.validate_on_submit(): |
|
|
|
|
|
if current_user.verify_password(form.old_password.data): |
|
|
|
|
|
current_user.password = form.password.data |
|
|
|
|
|
db.session.add(current_user) |
|
|
|
|
|
db.session.commit() |
|
|
|
|
|
flash('Your password has been updated') |
|
|
|
|
|
redirect(url_for('main.index')) |
|
|
|
|
|
else: |
|
|
|
|
|
flash('Invalid password.') |
|
|
|
|
|
return render_template('auth/change_password.html', form=form) |