[FEATURE] Resend confirmation emails
Closed this issue · 1 comments
jdabtieu commented
Is your feature request related to a problem? Please describe.
Sometimes a confirmation email doesn't get received the first time and people request a second confirmation.
Describe the solution you'd like
- An admin button on the users page to force verify
- Also, when logging in to an unverified account, a button to resend email
- should only resend if at least a minute has passed since last one
- delete unverified accounts after a week, with daily tasks
Describe alternatives you've considered
The current way is to hop into a Python + sqlite shell to do it manually
Additional context
We want something like this (derived from /register):
@app.route("/register", methods=["POST"])
@admin_required
def resend_register_confirmation():
user_id = request.form.get("user_id")
if not user_id:
flash("Must provide user ID", "danger")
return redirect("/admin/users")
user = db.execute("SELECT * FROM users WHERE id=:id", id=user_id)
if len(user) == 0:
flash("That user doesn't exist", "danger")
return redirect("/admin/users")
if user[0]["verified"] == 1: # or whatever this was called
flash("User is already verified", "danger")
return redirect("/admin/users")
token = create_jwt({'email': user[0]['email']}, app.config['SECRET_KEY'])
text = render_template('email/confirm_account.html',
username=user[0]['username'], token=token)
if not app.config['TESTING']:
send_email('CTFOJ Account Confirmation',
app.config['MAIL_DEFAULT_SENDER'], [email], text)
flash('Email sent!', 'success')
logger.info((f"User #{session['user_id']} ({session['username']}) has initiated another "
f"registration request for user #{user_id}"), extra={"section": "auth"})
return redirect("/admin/users")