mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
when email changes, verify new email #78
This commit is contained in:
parent
b435423b1e
commit
0eea7a2600
2 changed files with 6 additions and 2 deletions
|
@ -210,15 +210,17 @@ def verify_email(token):
|
||||||
flash('You have been banned.', 'error')
|
flash('You have been banned.', 'error')
|
||||||
return redirect(url_for('main.index'))
|
return redirect(url_for('main.index'))
|
||||||
if user.verified: # guard against users double-clicking the link in the email
|
if user.verified: # guard against users double-clicking the link in the email
|
||||||
|
flash(_('Thank you for verifying your email address.'))
|
||||||
return redirect(url_for('main.index'))
|
return redirect(url_for('main.index'))
|
||||||
user.verified = True
|
user.verified = True
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
if not user.waiting_for_approval():
|
if not user.waiting_for_approval() and user.private_key is None: # only finalize user set up if this is a brand new user. People can also end up doing this process when they change their email address in which case we DO NOT want to reset their keys, etc!
|
||||||
finalize_user_setup(user)
|
finalize_user_setup(user)
|
||||||
else:
|
else:
|
||||||
flash(_('Thank you for verifying your email address.'))
|
flash(_('Thank you for verifying your email address.'))
|
||||||
else:
|
else:
|
||||||
flash(_('Email address validation failed.'), 'error')
|
flash(_('Email address validation failed.'), 'error')
|
||||||
|
return redirect(url_for('main.index'))
|
||||||
if user.waiting_for_approval():
|
if user.waiting_for_approval():
|
||||||
return redirect(url_for('auth.please_wait'))
|
return redirect(url_for('auth.please_wait'))
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -107,10 +107,12 @@ def edit_profile(actor):
|
||||||
if current_user.id != user.id:
|
if current_user.id != user.id:
|
||||||
abort(401)
|
abort(401)
|
||||||
form = ProfileForm()
|
form = ProfileForm()
|
||||||
|
old_email = user.email
|
||||||
if form.validate_on_submit() and not current_user.banned:
|
if form.validate_on_submit() and not current_user.banned:
|
||||||
current_user.title = form.title.data
|
current_user.title = form.title.data
|
||||||
|
current_user.email = form.email.data.strip()
|
||||||
# Email address has changed - request verification of new address
|
# Email address has changed - request verification of new address
|
||||||
if form.email.data.strip() != current_user.email:
|
if form.email.data.strip() != old_email:
|
||||||
current_user.verified = False
|
current_user.verified = False
|
||||||
verification_token = random_token(16)
|
verification_token = random_token(16)
|
||||||
current_user.verification_token = verification_token
|
current_user.verification_token = verification_token
|
||||||
|
|
Loading…
Add table
Reference in a new issue