diff --git a/.gitignore b/.gitignore index d33992ec..89d4d9c1 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ db.sqlite .vscode .DS_Store config -static/node_modules \ No newline at end of file +static/node_modules +db.sqlite-journal \ No newline at end of file diff --git a/app/api/views/alias.py b/app/api/views/alias.py index 3effd83f..83e9a5d4 100644 --- a/app/api/views/alias.py +++ b/app/api/views/alias.py @@ -34,7 +34,7 @@ def get_aliases(): except (ValueError, TypeError): return jsonify(error="page_id must be provided in request query"), 400 - aliases: [AliasInfo] = get_alias_info(user.id, page_id=page_id) + aliases: [AliasInfo] = get_alias_info(user, page_id=page_id) return ( jsonify( diff --git a/app/auth/views/facebook.py b/app/auth/views/facebook.py index 3d590140..b59beceb 100644 --- a/app/auth/views/facebook.py +++ b/app/auth/views/facebook.py @@ -16,7 +16,7 @@ from app.extensions import db from app.log import LOG from app.models import User from .login_utils import after_login -from ...email_utils import can_be_used_as_personal_email +from ...email_utils import can_be_used_as_personal_email, email_already_used _authorization_base_url = "https://www.facebook.com/dialog/oauth" _token_url = "https://graph.facebook.com/oauth/access_token" @@ -112,7 +112,7 @@ def facebook_callback(): flash("Registration is closed", "error") return redirect(url_for("auth.login")) - if not can_be_used_as_personal_email(email): + if not can_be_used_as_personal_email(email) or email_already_used(email): flash( f"You cannot use {email} as your personal inbox.", "error", ) diff --git a/app/auth/views/github.py b/app/auth/views/github.py index a0488a7f..8f24f132 100644 --- a/app/auth/views/github.py +++ b/app/auth/views/github.py @@ -6,7 +6,7 @@ from app import email_utils from app.auth.base import auth_bp from app.auth.views.login_utils import after_login from app.config import GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET, URL, DISABLE_REGISTRATION -from app.email_utils import can_be_used_as_personal_email +from app.email_utils import can_be_used_as_personal_email, email_already_used from app.extensions import db from app.log import LOG from app.models import User @@ -89,7 +89,7 @@ def github_callback(): flash("Registration is closed", "error") return redirect(url_for("auth.login")) - if not can_be_used_as_personal_email(email): + if not can_be_used_as_personal_email(email) or email_already_used(email): flash( f"You cannot use {email} as your personal inbox.", "error", ) diff --git a/app/auth/views/google.py b/app/auth/views/google.py index 3538fed3..78792e60 100644 --- a/app/auth/views/google.py +++ b/app/auth/views/google.py @@ -10,7 +10,7 @@ from app.log import LOG from app.models import User, File from app.utils import random_string from .login_utils import after_login -from ...email_utils import can_be_used_as_personal_email +from ...email_utils import can_be_used_as_personal_email, email_already_used _authorization_base_url = "https://accounts.google.com/o/oauth2/v2/auth" _token_url = "https://www.googleapis.com/oauth2/v4/token" @@ -97,7 +97,7 @@ def google_callback(): flash("Registration is closed", "error") return redirect(url_for("auth.login")) - if not can_be_used_as_personal_email(email): + if not can_be_used_as_personal_email(email) or email_already_used(email): flash( f"You cannot use {email} as your personal inbox.", "error", ) diff --git a/app/auth/views/register.py b/app/auth/views/register.py index e4efa46d..3acb9a91 100644 --- a/app/auth/views/register.py +++ b/app/auth/views/register.py @@ -6,7 +6,7 @@ from wtforms import StringField, validators from app import email_utils, config from app.auth.base import auth_bp from app.config import URL, DISABLE_REGISTRATION -from app.email_utils import can_be_used_as_personal_email +from app.email_utils import can_be_used_as_personal_email, email_already_used from app.extensions import db from app.log import LOG from app.models import User, ActivationCode @@ -41,9 +41,7 @@ def register(): "You cannot use this email address as your personal inbox.", "error", ) else: - user = User.get_by(email=email) - - if user: + if email_already_used(email): flash(f"Email {email} already used", "error") else: LOG.debug("create user %s", form.email.data) diff --git a/app/dashboard/__init__.py b/app/dashboard/__init__.py index 4cc25e80..1a684cc4 100644 --- a/app/dashboard/__init__.py +++ b/app/dashboard/__init__.py @@ -14,4 +14,5 @@ from .views import ( domain_detail, lifetime_licence, directory, + mailbox, ) diff --git a/app/dashboard/templates/dashboard/alias_contact_manager.html b/app/dashboard/templates/dashboard/alias_contact_manager.html index 76333e23..1de72a56 100644 --- a/app/dashboard/templates/dashboard/alias_contact_manager.html +++ b/app/dashboard/templates/dashboard/alias_contact_manager.html @@ -15,13 +15,23 @@ diff --git a/app/dashboard/templates/dashboard/custom_alias.html b/app/dashboard/templates/dashboard/custom_alias.html index 984cdd0e..a3331ce5 100644 --- a/app/dashboard/templates/dashboard/custom_alias.html +++ b/app/dashboard/templates/dashboard/custom_alias.html @@ -48,6 +48,25 @@ + {% if mailboxes|length > 1 %} +
+
+ +
+ The mailbox that owns this alias. +
+
+
+ {% else %} + + {% endif %} +