diff --git a/app/api/views/auth.py b/app/api/views/auth.py index b817bda1..5b1ce087 100644 --- a/app/api/views/auth.py +++ b/app/api/views/auth.py @@ -12,7 +12,7 @@ from app.api.base import api_bp from app.config import FLASK_SECRET, DISABLE_REGISTRATION from app.dashboard.views.setting import send_reset_password_email from app.email_utils import ( - email_domain_can_be_used_as_mailbox, + email_can_be_used_as_mailbox, personal_email_already_used, send_email, render, @@ -89,9 +89,7 @@ def auth_register(): if DISABLE_REGISTRATION: return jsonify(error="registration is closed"), 400 - if not email_domain_can_be_used_as_mailbox(email) or personal_email_already_used( - email - ): + if not email_can_be_used_as_mailbox(email) or personal_email_already_used(email): return jsonify(error=f"cannot use {email} as personal inbox"), 400 if not password or len(password) < 8: @@ -249,9 +247,9 @@ def auth_facebook(): if not user: if DISABLE_REGISTRATION: return jsonify(error="registration is closed"), 400 - if not email_domain_can_be_used_as_mailbox( + if not email_can_be_used_as_mailbox(email) or personal_email_already_used( email - ) or personal_email_already_used(email): + ): return jsonify(error=f"cannot use {email} as personal inbox"), 400 LOG.d("create facebook user with %s", user_info) @@ -302,9 +300,9 @@ def auth_google(): if not user: if DISABLE_REGISTRATION: return jsonify(error="registration is closed"), 400 - if not email_domain_can_be_used_as_mailbox( + if not email_can_be_used_as_mailbox(email) or personal_email_already_used( email - ) or personal_email_already_used(email): + ): return jsonify(error=f"cannot use {email} as personal inbox"), 400 LOG.d("create Google user with %s", user_info) diff --git a/app/api/views/mailbox.py b/app/api/views/mailbox.py index 517148ac..b70085df 100644 --- a/app/api/views/mailbox.py +++ b/app/api/views/mailbox.py @@ -9,7 +9,7 @@ from app.dashboard.views.mailbox import send_verification_email from app.dashboard.views.mailbox_detail import verify_mailbox_change from app.email_utils import ( mailbox_already_used, - email_domain_can_be_used_as_mailbox, + email_can_be_used_as_mailbox, ) from app.extensions import db from app.models import Mailbox @@ -34,7 +34,7 @@ def create_mailbox(): if mailbox_already_used(mailbox_email, user): return jsonify(error=f"{mailbox_email} already used"), 400 - elif not email_domain_can_be_used_as_mailbox(mailbox_email): + elif not email_can_be_used_as_mailbox(mailbox_email): return ( jsonify( error=f"{mailbox_email} cannot be used. Please note a mailbox cannot " @@ -118,7 +118,7 @@ def update_mailbox(mailbox_id): if mailbox_already_used(new_email, user): return jsonify(error=f"{new_email} already used"), 400 - elif not email_domain_can_be_used_as_mailbox(new_email): + elif not email_can_be_used_as_mailbox(new_email): return ( jsonify( error=f"{new_email} cannot be used. Please note a mailbox cannot " diff --git a/app/auth/views/register.py b/app/auth/views/register.py index e25ab3ec..70dcb5f8 100644 --- a/app/auth/views/register.py +++ b/app/auth/views/register.py @@ -9,7 +9,7 @@ from app.auth.base import auth_bp from app.auth.views.login_utils import get_referral from app.config import URL, HCAPTCHA_SECRET, HCAPTCHA_SITEKEY from app.email_utils import ( - email_domain_can_be_used_as_mailbox, + email_can_be_used_as_mailbox, personal_email_already_used, ) from app.extensions import db @@ -67,7 +67,7 @@ def register(): ) email = form.email.data.strip().lower() - if not email_domain_can_be_used_as_mailbox(email): + if not email_can_be_used_as_mailbox(email): flash("You cannot use this email address as your personal inbox.", "error") else: diff --git a/app/dashboard/views/mailbox.py b/app/dashboard/views/mailbox.py index a14333fa..0edd2839 100644 --- a/app/dashboard/views/mailbox.py +++ b/app/dashboard/views/mailbox.py @@ -8,7 +8,7 @@ from wtforms.fields.html5 import EmailField from app.config import EMAIL_DOMAIN, ALIAS_DOMAINS, MAILBOX_SECRET, URL from app.dashboard.base import dashboard_bp from app.email_utils import ( - email_domain_can_be_used_as_mailbox, + email_can_be_used_as_mailbox, mailbox_already_used, render, send_email, @@ -88,7 +88,7 @@ def mailbox_route(): if mailbox_already_used(mailbox_email, current_user): flash(f"{mailbox_email} already used", "error") - elif not email_domain_can_be_used_as_mailbox(mailbox_email): + elif not email_can_be_used_as_mailbox(mailbox_email): flash(f"You cannot use {mailbox_email}.", "error") else: new_mailbox = Mailbox.create( diff --git a/app/dashboard/views/mailbox_detail.py b/app/dashboard/views/mailbox_detail.py index fc0a519d..1f422397 100644 --- a/app/dashboard/views/mailbox_detail.py +++ b/app/dashboard/views/mailbox_detail.py @@ -10,7 +10,7 @@ from wtforms.fields.html5 import EmailField from app.config import ENFORCE_SPF, MAILBOX_SECRET from app.config import URL from app.dashboard.base import dashboard_bp -from app.email_utils import email_domain_can_be_used_as_mailbox +from app.email_utils import email_can_be_used_as_mailbox from app.email_utils import mailbox_already_used, render, send_email from app.extensions import db from app.log import LOG @@ -52,7 +52,7 @@ def mailbox_detail_route(mailbox_id): email=new_email ): flash(f"Email {new_email} already used", "error") - elif not email_domain_can_be_used_as_mailbox(new_email): + elif not email_can_be_used_as_mailbox(new_email): flash("You cannot use this email address as your mailbox", "error") else: mailbox.new_email = new_email diff --git a/app/dashboard/views/setting.py b/app/dashboard/views/setting.py index 2282285d..5b7730d3 100644 --- a/app/dashboard/views/setting.py +++ b/app/dashboard/views/setting.py @@ -22,7 +22,7 @@ from app import s3, email_utils from app.config import URL, FIRST_ALIAS_DOMAIN from app.dashboard.base import dashboard_bp from app.email_utils import ( - email_domain_can_be_used_as_mailbox, + email_can_be_used_as_mailbox, personal_email_already_used, ) from app.extensions import db @@ -90,7 +90,7 @@ def setting(): ): flash(f"Email {new_email} already used", "error") new_email_valid = False - elif not email_domain_can_be_used_as_mailbox(new_email): + elif not email_can_be_used_as_mailbox(new_email): flash( "You cannot use this email address as your personal inbox.", "error",