Procházet zdrojové kódy

added validations for shell enum

tags/release-00
gashapwn před 3 roky
rodič
revize
d74d38a582
1 změnil soubory, kde provedl 14 přidání a 9 odebrání
  1. +14
    -9
      app.py

+ 14
- 9
app.py Zobrazit soubor

@@ -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(
lambda k : (k, conf_obj["shell"][k]),
list(conf_obj["shell"].keys())
)
SHELL_TUP_LIST
), ),
"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")


Načítá se…
Zrušit
Uložit