|
@@ -5,6 +5,7 @@ from wtforms import StringField, validators
|
|
|
|
|
|
from app.config import EMAIL_SERVERS_WITH_PRIORITY
|
|
|
from app.dashboard.base import dashboard_bp
|
|
|
+from app.email_utils import get_email_domain_part
|
|
|
from app.extensions import db
|
|
|
from app.models import CustomDomain
|
|
|
|
|
@@ -30,9 +31,15 @@ def custom_domain():
|
|
|
return redirect(url_for("dashboard.custom_domain"))
|
|
|
|
|
|
if new_custom_domain_form.validate():
|
|
|
- new_domain = new_custom_domain_form.domain.data.strip()
|
|
|
+ new_domain = new_custom_domain_form.domain.data.lower().strip()
|
|
|
if CustomDomain.get_by(domain=new_domain):
|
|
|
flash(f"{new_domain} already added", "warning")
|
|
|
+ elif get_email_domain_part(current_user.email) == new_domain:
|
|
|
+ flash(
|
|
|
+ "You cannot add a domain that you are currently using for your personal email. "
|
|
|
+ "Please change your personal email to your real email",
|
|
|
+ "error",
|
|
|
+ )
|
|
|
else:
|
|
|
new_custom_domain = CustomDomain.create(
|
|
|
domain=new_domain, user_id=current_user.id
|