Skip to content
Open
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
38 changes: 7 additions & 31 deletions auth_backend/auth_plugins/email.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import hashlib
import logging
import re
from typing import Annotated, Self

from annotated_types import MinLen
Expand Down Expand Up @@ -27,37 +28,12 @@
logger = logging.getLogger(__name__)


def check_email(v):
restricted: set[str] = {
'"',
'#',
'&',
"'",
'(',
')',
'*',
',',
'/',
';',
'<',
'>',
'?',
'[',
'\\',
']',
'^',
'`',
'{',
'|',
'}',
'~',
'\n',
'\r',
}
if "@" not in v:
raise ValueError()
if set(v) & restricted:
raise ValueError()
EMAIL_CONST_REGEX = re.compile(
r'^[a-zA-Z0-9_.+\\-%]+@[a-zA-Z0-9\\-]+\\.[a-zA-Z0-9\\-.]+$')

def email_check(v):
if not EMAIL_CONST_REGEX.match(v):
raise ValueError("Неверный формат email")
return v


Expand Down
Loading