Jun 29 - Update: Fail2ban, welcome email, dunning sequence, escalation

This commit is contained in:
2026-06-29 13:47:57 -04:00
parent c133b5d419
commit b00bbba2da
14 changed files with 414 additions and 1 deletions
+24
View File
@@ -25,6 +25,23 @@ from wtforms.validators import DataRequired, Email, Length, EqualTo, ValidationE
bp = Blueprint('signup', __name__, url_prefix='/signup')
logger = logging.getLogger(__name__)
def _send_welcome_email(to_email, login_url, tenant_name, plan_code, trial_ends_at):
"""Fire a welcome email in a background thread — never blocks the request."""
try:
from app.billing.emails import send_billing_email
ends_str = (trial_ends_at.strftime('%B %d, %Y')
if hasattr(trial_ends_at, 'strftime') else str(trial_ends_at or ''))
send_billing_email(to_email, 'welcome', {
'tenant_name': tenant_name,
'login_url': login_url,
'trial_days': 14,
'trial_ends_at': ends_str,
'plan_name': plan_code.title(),
})
except Exception as exc:
logger.error('SIGNUP | welcome_email_failed | to=%s err=%s', to_email, exc)
_SLUG_RE = re.compile(r'^[a-z0-9](?:[a-z0-9-]{0,30}[a-z0-9])?$')
@@ -119,6 +136,13 @@ def index():
login_url = f'https://{slug}.{base_domain}/auth/login'
logger.info('SIGNUP | provisioned | slug=%s plan=%s tenant_id=%s',
slug, plan_code, info['tenant_id'])
_send_welcome_email(
to_email = email,
login_url = login_url,
tenant_name = company,
plan_code = plan_code,
trial_ends_at = info.get('trial_ends_at'),
)
return render_template('signup/success.html',
login_url=login_url,
slug=slug,