Skip to content
Snippets Groups Projects
Commit fb4530d2 authored by Martin Mareš's avatar Martin Mareš
Browse files

Web: Field Email umí kontrolovat domény

parent 213df204
No related branches found
No related tags found
1 merge request!130Přísnější kontroly mailových adres
This commit is part of merge request !130. Comments created here will be created in the context of that merge request.
...@@ -74,13 +74,16 @@ class Points(Decimal): ...@@ -74,13 +74,16 @@ class Points(Decimal):
class Email(Stripped, EmailField): class Email(Stripped, EmailField):
def __init__(self, label="E-mail", validators=None, **kwargs): check_existence: bool
def __init__(self, label="E-mail", validators=None, check_existence: bool = False, **kwargs):
self.check_existence = check_existence
super().__init__(label, validators, **kwargs) super().__init__(label, validators, **kwargs)
def pre_validate(field, form): def pre_validate(field, form):
if field.data: if field.data:
try: try:
field.data = mo.users.normalize_email(field.data) field.data = mo.users.normalize_email(field.data, check_existence=field.check_existence)
except mo.CheckError as e: except mo.CheckError as e:
raise wtforms.ValidationError(str(e)) raise wtforms.ValidationError(str(e))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment