Переглянути джерело

sanitize mailbox before creating: remove empty space

Son NK 4 роки тому
батько
коміт
d81ad2fd12
2 змінених файлів з 4 додано та 2 видалено
  1. 1 1
      app/api/views/mailbox.py
  2. 3 1
      app/dashboard/views/mailbox.py

+ 1 - 1
app/api/views/mailbox.py

@@ -30,7 +30,7 @@ def create_mailbox():
 
 
     """
     """
     user = g.user
     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):
     if mailbox_already_used(mailbox_email, user):
         return jsonify(error=f"{mailbox_email} already used"), 400
         return jsonify(error=f"{mailbox_email} already used"), 400

+ 3 - 1
app/dashboard/views/mailbox.py

@@ -82,7 +82,9 @@ def mailbox_route():
                 return redirect(url_for("dashboard.mailbox_route"))
                 return redirect(url_for("dashboard.mailbox_route"))
 
 
             if new_mailbox_form.validate():
             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):
                 if mailbox_already_used(mailbox_email, current_user):
                     flash(f"{mailbox_email} already used", "error")
                     flash(f"{mailbox_email} already used", "error")