added validations for shell enum

This commit is contained in:
gashapwn 2020-11-28 01:58:23 +00:00
parent 8fafc34bcb
commit d74d38a582

23
app.py
View File

@ -31,11 +31,6 @@ CONF_PATH = str(WORKING_DIR) + "lyadmin.conf.json"
MAX_PUB_KEY_LEN = 5000
# SHELL_ENUM = map(
# lambda k : (k, conf_obj["shell"][k]),
# list(conf_obj["shell"].keys())
# )
# Account requests are given ID numbers
# the first request will have the below
@ -46,6 +41,14 @@ INIT_REQ_ID = "00000"
with open(CONF_PATH) as c: conf_json_str = c.read()
conf_obj = json.loads(conf_json_str)
# A list of all the shell enums
SHELL_TUP_LIST = list(map(
lambda k : (
k, conf_obj["shell"][k]
),
list(conf_obj["shell"].keys())
))
# The main home page
@app.route("/")
def home():
@ -111,10 +114,7 @@ def req():
"shell of choice": Widg(
"shell",
"choice",
map(
lambda k : (k, conf_obj["shell"][k]),
list(conf_obj["shell"].keys())
)
SHELL_TUP_LIST
),
"have you read the rules?": Widg(
@ -154,6 +154,11 @@ def signup():
else:
email = "NO_EMAIL"
# Validate shell
if(not shell in conf_obj["shell"]):
print("failed shell validation")
return handle_invalid_data(req)
# Validate email
if( not re.search("^[a-z0-9]+[\._]?[a-z0-9]+[@]\w+[.]\w{2,10}$", email)):
print("failed email validation")