feat: Add email validation
All checks were successful
Build Docker / Build Image (push) Successful in 31s
All checks were successful
Build Docker / Build Image (push) Successful in 31s
This commit is contained in:
parent
93f45eec12
commit
5e6af2bcc8
10
main.py
10
main.py
@ -6,6 +6,7 @@ import gift
|
||||
import json
|
||||
import schedule
|
||||
import time
|
||||
from email_validator import validate_email, EmailNotValidError
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
@ -36,7 +37,6 @@ def index():
|
||||
resp = make_response(render_template('index.html', hidden=params['r'],address=address))
|
||||
resp.set_cookie('r', params['r'], max_age=60*60*24)
|
||||
return resp
|
||||
|
||||
return render_template('index.html',address=address)
|
||||
|
||||
|
||||
@ -59,6 +59,14 @@ def submit():
|
||||
if 'r' in request.cookies:
|
||||
hidden = request.cookies['r']
|
||||
|
||||
# Validate email
|
||||
try:
|
||||
emailinfo = validate_email(email, check_deliverability=False)
|
||||
email = emailinfo.normalized
|
||||
except EmailNotValidError as e:
|
||||
return render_template('error.html',error='Invalid email address',address=address)
|
||||
|
||||
|
||||
status = gift.gift(name, email, hidden, ip)
|
||||
print(status,flush=True)
|
||||
|
||||
|
@ -4,3 +4,5 @@ gunicorn
|
||||
requests
|
||||
pyotp
|
||||
schedule
|
||||
email-validator
|
||||
py3dns
|
Loading…
Reference in New Issue
Block a user