2022-05-13 08:51:58 +02:00
|
|
|
from app.extensions import limiter
|
2022-05-20 18:15:54 +02:00
|
|
|
from app.models import Alias
|
2022-05-06 17:04:41 +02:00
|
|
|
from app.onboarding.base import onboarding_bp
|
2022-05-13 08:51:58 +02:00
|
|
|
from app.email_utils import send_test_email_alias
|
|
|
|
from flask import render_template, request, flash
|
|
|
|
from flask_login import current_user, login_required
|
|
|
|
from flask_wtf import FlaskForm
|
|
|
|
from wtforms import StringField, validators
|
2022-05-06 17:04:41 +02:00
|
|
|
|
|
|
|
|
2022-05-13 08:51:58 +02:00
|
|
|
class SendEmailForm(FlaskForm):
|
|
|
|
email = StringField("Email", validators=[validators.DataRequired()])
|
|
|
|
|
|
|
|
|
|
|
|
@onboarding_bp.route("/final", methods=["GET", "POST"])
|
|
|
|
@login_required
|
|
|
|
@limiter.limit("10/minute")
|
2022-05-06 17:04:41 +02:00
|
|
|
def final():
|
2022-05-13 08:51:58 +02:00
|
|
|
form = SendEmailForm(request.form)
|
|
|
|
if form.validate_on_submit():
|
2022-05-20 18:15:54 +02:00
|
|
|
alias = Alias.get_by(email=form.email.data)
|
|
|
|
if alias and alias.user_id == current_user.id:
|
2024-07-03 14:59:16 +02:00
|
|
|
send_test_email_alias(current_user, alias.email)
|
2022-05-20 18:15:54 +02:00
|
|
|
flash("An email is sent to your alias", "success")
|
2022-05-13 08:51:58 +02:00
|
|
|
|
2022-05-06 17:04:41 +02:00
|
|
|
return render_template(
|
|
|
|
"onboarding/final.html",
|
2022-05-13 08:51:58 +02:00
|
|
|
form=form,
|
2022-05-06 17:04:41 +02:00
|
|
|
)
|