|
|
|
@ -402,7 +402,7 @@ def profile():
|
|
|
|
|
form = forms.ProfileForm(flask.request.form)
|
|
|
|
|
if flask.request.method == 'POST' and form.validate():
|
|
|
|
|
user = flask.g.user
|
|
|
|
|
new_email = form.email.data
|
|
|
|
|
new_email = form.email.data.strip()
|
|
|
|
|
new_password = form.new_password.data
|
|
|
|
|
|
|
|
|
|
if new_email:
|
|
|
|
@ -412,20 +412,26 @@ def profile():
|
|
|
|
|
'<strong>Email change failed!</strong> Incorrect password.'), 'danger')
|
|
|
|
|
return flask.redirect('/profile')
|
|
|
|
|
user.email = form.email.data
|
|
|
|
|
|
|
|
|
|
flask.flash(flask.Markup(
|
|
|
|
|
'<strong>Email successfully changed!</strong>'), 'info')
|
|
|
|
|
if new_password:
|
|
|
|
|
if form.current_password.data != user.password_hash:
|
|
|
|
|
flask.flash(flask.Markup(
|
|
|
|
|
'<strong>Password change failed!</strong> Incorrect password.'), 'danger')
|
|
|
|
|
return flask.redirect('/profile')
|
|
|
|
|
user.password_hash = form.new_password.data
|
|
|
|
|
flask.flash(flask.Markup(
|
|
|
|
|
'<strong>Password successfully changed!</strong>'), 'info')
|
|
|
|
|
|
|
|
|
|
db.session.add(user)
|
|
|
|
|
db.session.commit()
|
|
|
|
|
|
|
|
|
|
flask.g.user = user
|
|
|
|
|
return flask.redirect('/profile')
|
|
|
|
|
|
|
|
|
|
current_email = models.User.by_id(flask.g.user.id).email
|
|
|
|
|
|
|
|
|
|
return flask.render_template('profile.html', form=form)
|
|
|
|
|
return flask.render_template('profile.html', form=form, email=current_email)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/user/activate/<payload>')
|
|
|
|
|