app-MAIL-temp/app/onboarding/views/final.py
Adrià Casajús 2d841e9bc0
Update render function to receive user always as a param (#2141)
* Update render function to receive user always as a param

(cherry picked from commit fb53632298b08ab40bb82b8c8724a0bf254b2632)

* Add user to the kwargs
2024-07-03 12:59:16 +00:00

30 lines
952 B
Python

from app.extensions import limiter
from app.models import Alias
from app.onboarding.base import onboarding_bp
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
class SendEmailForm(FlaskForm):
email = StringField("Email", validators=[validators.DataRequired()])
@onboarding_bp.route("/final", methods=["GET", "POST"])
@login_required
@limiter.limit("10/minute")
def final():
form = SendEmailForm(request.form)
if form.validate_on_submit():
alias = Alias.get_by(email=form.email.data)
if alias and alias.user_id == current_user.id:
send_test_email_alias(current_user, alias.email)
flash("An email is sent to your alias", "success")
return render_template(
"onboarding/final.html",
form=form,
)