Browse Source

added validations for shell enum

tags/release-00
gashapwn 3 years ago
parent
commit
d74d38a582
1 changed files with 14 additions and 9 deletions
  1. +14
    -9
      app.py

+ 14
- 9
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")


Loading…
Cancel
Save