Development
This commit is contained in:
parent
c561f2f548
commit
1beb660be1
8 changed files with 280 additions and 48 deletions
|
|
@ -37,6 +37,39 @@ def accountdetails_save():
|
|||
return redirect(f'/{_PAGE}')
|
||||
|
||||
|
||||
@bp.route('/action/preferences/email_change_request', methods=['POST'])
|
||||
@auth.require_level('viewer')
|
||||
def email_change_request():
|
||||
new_email = sanitize.email(request.form.get('new_email', '').strip())
|
||||
if not new_email:
|
||||
flash('A valid email address is required.', 'error')
|
||||
return redirect(f'/{_PAGE}')
|
||||
|
||||
current_email = session.get('email_address', '').lower()
|
||||
if new_email == current_email:
|
||||
flash('That is already your current email address.', 'error')
|
||||
return redirect(f'/{_PAGE}')
|
||||
|
||||
if config_utils.get_account_by_email(new_email):
|
||||
flash('That email address is already in use.', 'error')
|
||||
return redirect(f'/{_PAGE}')
|
||||
|
||||
try:
|
||||
con = config_utils.open_accounts_db()
|
||||
con.execute(
|
||||
'UPDATE accounts SET requested_email=? WHERE account_id=?',
|
||||
(new_email, session.get('account_id', ''))
|
||||
)
|
||||
con.commit()
|
||||
con.close()
|
||||
except Exception as exc:
|
||||
flash(f'Could not submit request: {exc}', 'error')
|
||||
return redirect(f'/{_PAGE}')
|
||||
|
||||
flash('Email change request submitted. A manager will review it.', 'success')
|
||||
return redirect(f'/{_PAGE}')
|
||||
|
||||
|
||||
@bp.route('/action/preferences/changepassword_save', methods=['POST'])
|
||||
@auth.require_level('viewer')
|
||||
def changepassword_save():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue