Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1421 as a shop owner i can block sign ups from email domains i ch #1422

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pr-demo-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ jobs:
cd tests/browser-automated-tests-playwright
python3 run-playwright-tests.py

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: Screenshots-and-video-artifacts
Expand Down
34 changes: 34 additions & 0 deletions migrations/versions/abfb5c2f77e6_add_spamemaildomain.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""add SpamEmailDomain

Revision ID: abfb5c2f77e6
Revises: abc1ff0c85e0
Create Date: 2024-11-11 21:27:48.094799

"""

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "abfb5c2f77e6"
down_revision = "abc1ff0c85e0"
branch_labels = None
depends_on = None


def upgrade():
op.create_table(
"spam_email_domain",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("uuid", sa.String(), nullable=True),
sa.Column("ts", sa.DateTime(), nullable=True),
sa.Column("domain", sa.String(), nullable=True),
sa.Column("archived", sa.Boolean(), nullable=True),
sa.Column("created_at", sa.DateTime(), nullable=True),
sa.PrimaryKeyConstraint("id"),
)


def downgrade():
pass
1 change: 0 additions & 1 deletion settings.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ SUPPORTED_CURRENCIES: "GBP,USD,EUR"
# Anti spam
ANTI_SPAM_SHOP_NAMES_MODEL_FULL_PATH: "/path/to/classifier.pkl"


# Optional
TELEGRAM_TOKEN:
TELEGRAM_CHAT_ID:
Expand Down
12 changes: 12 additions & 0 deletions subscribie/blueprints/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
UpcomingInvoice,
Document,
PlanQuestionAssociation,
SpamEmailDomain,
)
from .subscription import (
update_stripe_subscription_statuses,
Expand Down Expand Up @@ -992,6 +993,17 @@ def set_stripe_livemode():
@admin.route("/connect/stripe-connect", methods=["GET"])
@login_required
def stripe_connect():
# Verify that shop owner email address is not
# a suspected SUSPECTED_SPAM_EMAIL_DOMAINS
user = User.query.first()
SUSPECTED_SPAM_EMAIL_DOMAINS = [d.domain for d in SpamEmailDomain.query.all()]
user_email_domain = user.email.split("@")[1]
if user_email_domain in SUSPECTED_SPAM_EMAIL_DOMAINS:
log.error(
f"SUSPECTED_SPAM_EMAIL_DOMAIN {user_email_domain} "
"attempted to connect stripe"
)
return "<h1>Please contact support before connecting Stripe, thank you.</h1>"
setting = Setting.query.first()
shop_activated = setting.shop_activated
SERVER_NAME = settings.get("SERVER_NAME")
Expand Down
11 changes: 10 additions & 1 deletion subscribie/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from sqlalchemy import Column
from sqlalchemy import Boolean
from sqlalchemy import PrimaryKeyConstraint
from sqlalchemy import desc

from typing import Optional
import datetime
Expand Down Expand Up @@ -1400,3 +1399,13 @@ class PriceListRule(database.Model, HasCreatedAt):
secondary=association_table_price_list_to_rule,
back_populates="rules",
)


class SpamEmailDomain(database.Model, HasArchived, HasCreatedAt):
__tablename__ = "spam_email_domain"
id = database.Column(database.Integer(), primary_key=True)
uuid = database.Column(database.String(), default=uuid_string)
ts = database.Column(
database.DateTime, default=lambda: datetime.datetime.now(datetime.UTC)
)
domain = database.Column(database.String())
Loading