Merge pull request #50 from jameswthorne/no-zero-length

Don't allow zero length form submissions
This commit is contained in:
Nicholas Charriere 2017-03-04 10:52:09 -08:00 committed by GitHub
commit e7f8a40065

View file

@ -65,16 +65,19 @@ def get_password(key):
redis_client.delete(key)
return password
def empty(value):
if not value:
return True
def clean_input():
"""
Make sure we're not getting bad data from the front end,
format data to be machine readable
"""
if 'password' not in request.form:
if empty(request.form.get('password', '')):
abort(400)
if 'ttl' not in request.form:
if empty(request.form.get('ttl', '')):
abort(400)
time_period = request.form['ttl'].lower()