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 json
|
||||||
import schedule
|
import schedule
|
||||||
import time
|
import time
|
||||||
|
from email_validator import validate_email, EmailNotValidError
|
||||||
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
@ -36,7 +37,6 @@ def index():
|
|||||||
resp = make_response(render_template('index.html', hidden=params['r'],address=address))
|
resp = make_response(render_template('index.html', hidden=params['r'],address=address))
|
||||||
resp.set_cookie('r', params['r'], max_age=60*60*24)
|
resp.set_cookie('r', params['r'], max_age=60*60*24)
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
return render_template('index.html',address=address)
|
return render_template('index.html',address=address)
|
||||||
|
|
||||||
|
|
||||||
@ -59,6 +59,14 @@ def submit():
|
|||||||
if 'r' in request.cookies:
|
if 'r' in request.cookies:
|
||||||
hidden = request.cookies['r']
|
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)
|
status = gift.gift(name, email, hidden, ip)
|
||||||
print(status,flush=True)
|
print(status,flush=True)
|
||||||
|
|
||||||
|
@ -3,4 +3,6 @@ python-dotenv
|
|||||||
gunicorn
|
gunicorn
|
||||||
requests
|
requests
|
||||||
pyotp
|
pyotp
|
||||||
schedule
|
schedule
|
||||||
|
email-validator
|
||||||
|
py3dns
|
Loading…
Reference in New Issue
Block a user