added validations for shell enum
This commit is contained in:
parent
8fafc34bcb
commit
d74d38a582
23
app.py
23
app.py
@ -31,11 +31,6 @@ CONF_PATH = str(WORKING_DIR) + "lyadmin.conf.json"
|
|||||||
|
|
||||||
MAX_PUB_KEY_LEN = 5000
|
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
|
# Account requests are given ID numbers
|
||||||
# the first request will have the below
|
# 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()
|
with open(CONF_PATH) as c: conf_json_str = c.read()
|
||||||
conf_obj = json.loads(conf_json_str)
|
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
|
# The main home page
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def home():
|
def home():
|
||||||
@ -111,10 +114,7 @@ def req():
|
|||||||
"shell of choice": Widg(
|
"shell of choice": Widg(
|
||||||
"shell",
|
"shell",
|
||||||
"choice",
|
"choice",
|
||||||
map(
|
SHELL_TUP_LIST
|
||||||
lambda k : (k, conf_obj["shell"][k]),
|
|
||||||
list(conf_obj["shell"].keys())
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
|
|
||||||
"have you read the rules?": Widg(
|
"have you read the rules?": Widg(
|
||||||
@ -154,6 +154,11 @@ def signup():
|
|||||||
else:
|
else:
|
||||||
email = "NO_EMAIL"
|
email = "NO_EMAIL"
|
||||||
|
|
||||||
|
# Validate shell
|
||||||
|
if(not shell in conf_obj["shell"]):
|
||||||
|
print("failed shell validation")
|
||||||
|
return handle_invalid_data(req)
|
||||||
|
|
||||||
# Validate email
|
# Validate email
|
||||||
if( not re.search("^[a-z0-9]+[\._]?[a-z0-9]+[@]\w+[.]\w{2,10}$", email)):
|
if( not re.search("^[a-z0-9]+[\._]?[a-z0-9]+[@]\w+[.]\w{2,10}$", email)):
|
||||||
print("failed email validation")
|
print("failed email validation")
|
||||||
|
Loading…
Reference in New Issue
Block a user