diff --git a/app/auth/forms.py b/app/auth/forms.py index 3c92c7ed..0e54ebf7 100644 --- a/app/auth/forms.py +++ b/app/auth/forms.py @@ -47,7 +47,7 @@ class PasswordResetRequestForm(FlaskForm): submit = SubmitField('Reset Password') -class ChangeProfileForm(FlaskForm): +class ChangeAccountForm(FlaskForm): email = StringField('Email', validators=[Optional(), Length(1, 64), Email()]) username = StringField('Username', validators=[ diff --git a/app/auth/views.py b/app/auth/views.py index 7a6a3836..657ef019 100644 --- a/app/auth/views.py +++ b/app/auth/views.py @@ -2,7 +2,7 @@ from flask import flash, redirect, render_template, request, url_for from flask_login import current_user, login_required, login_user, logout_user from . import auth from .. import db -from .forms import ChangeProfileForm, LoginForm, PasswordResetForm, PasswordResetRequestForm, RegistrationForm +from .forms import ChangeAccountForm, LoginForm, PasswordResetForm, PasswordResetRequestForm, RegistrationForm from ..email import send_email from ..models import User @@ -20,7 +20,7 @@ def login(): if next is None or not next.startswith('/'): next = url_for('main.index') return redirect(next) - flash('Invalid username or password.') + flash('Invalid username or password.') return render_template('auth/login.html.j2', form=form, title='Log in') @@ -125,10 +125,10 @@ def password_reset(token): title='Password Reset') -@auth.route('/profile', methods=['GET', 'POST']) +@auth.route('/account', methods=['GET', 'POST']) @login_required -def profile(): - form = ChangeProfileForm() +def account(): + form = ChangeAccountForm() if form.validate_on_submit(): flash('It is just a test, nothing changed.') if form.username.data: @@ -138,8 +138,10 @@ def profile(): current_user.email = form.email.data current_user.confirmed = False db.session.add(current_user) + resend_confirmation() + if form.password.data: + current_user.password = form.password.data db.session.commit() - resend_confirmation() - return redirect(url_for('auth.profile')) - return render_template('auth/profile.html.j2', form=form, - title='Profile') + return redirect(url_for('auth.account')) + return render_template('auth/account.html.j2', form=form, + title='Account') diff --git a/app/templates/auth/profile.html.j2 b/app/templates/auth/account.html.j2 similarity index 79% rename from app/templates/auth/profile.html.j2 rename to app/templates/auth/account.html.j2 index 5d81a6c3..50c3e90c 100644 --- a/app/templates/auth/profile.html.j2 +++ b/app/templates/auth/account.html.j2 @@ -2,15 +2,16 @@ {% block page_content %}