sanitize mailbox before creating: remove empty space

This commit is contained in:
Son NK 2020-09-17 17:02:50 +02:00
parent 5f8fff5af3
commit d81ad2fd12
2 changed files with 4 additions and 2 deletions

View File

@ -30,7 +30,7 @@ def create_mailbox():
"""
user = g.user
mailbox_email = request.get_json().get("email").lower().strip()
mailbox_email = request.get_json().get("email").lower().strip().replace(" ", "")
if mailbox_already_used(mailbox_email, user):
return jsonify(error=f"{mailbox_email} already used"), 400

View File

@ -82,7 +82,9 @@ def mailbox_route():
return redirect(url_for("dashboard.mailbox_route"))
if new_mailbox_form.validate():
mailbox_email = new_mailbox_form.email.data.lower().strip()
mailbox_email = (
new_mailbox_form.email.data.lower().strip().replace(" ", "")
)
if mailbox_already_used(mailbox_email, current_user):
flash(f"{mailbox_email} already used", "error")