feat(backend): migrate auth and notifications off email
This commit is contained in:
35
apps/users/email_identity.py
Normal file
35
apps/users/email_identity.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from __future__ import annotations
|
||||
|
||||
PLACEHOLDER_EMAIL_SUFFIX = "@noemail.local"
|
||||
|
||||
|
||||
def normalize_email_identity(value: str | None) -> str | None:
|
||||
if value is None:
|
||||
return None
|
||||
normalized = value.strip().lower()
|
||||
return normalized or None
|
||||
|
||||
|
||||
def normalize_mobile_number(value: str | None) -> str | None:
|
||||
if value is None:
|
||||
return None
|
||||
normalized = "".join(ch for ch in value if ch.isdigit())
|
||||
return normalized or None
|
||||
|
||||
|
||||
def is_valid_mobile_number(value: str | None) -> bool:
|
||||
normalized = normalize_mobile_number(value)
|
||||
return bool(normalized and len(normalized) == 11 and normalized.startswith("09"))
|
||||
|
||||
|
||||
def mask_mobile(value: str | None) -> str | None:
|
||||
if not value:
|
||||
return None
|
||||
if len(value) <= 4:
|
||||
return value
|
||||
return f"{value[:2]}{'*' * max(len(value) - 6, 1)}{value[-4:]}"
|
||||
|
||||
|
||||
def is_placeholder_email(value: str | None) -> bool:
|
||||
normalized = normalize_email_identity(value)
|
||||
return bool(normalized and normalized.endswith(PLACEHOLDER_EMAIL_SUFFIX))
|
||||
Reference in New Issue
Block a user