From edfb553df6d8e699066583faa1f4146cf24def72 Mon Sep 17 00:00:00 2001 From: Raffu Khondaker <2022rkhondak@tjhsst.edu> Date: Thu, 4 Jun 2020 22:43:35 -0400 Subject: [PATCH] login checks --- commands.py | 22 +++++++++++++++++++--- run.py | 3 ++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/commands.py b/commands.py index 4d92e00..da105ee 100644 --- a/commands.py +++ b/commands.py @@ -6,6 +6,10 @@ import argparse #already ccrerrated account through website, has to login +def update(): + #get data from database + return + def yesorno(question): questions = [ { @@ -42,7 +46,7 @@ def login(): if(user["webmail"] == data[i]["webmail"] and user["password"]) == data[i]["password"]: print("Logged in!") return data[i] - print("Error in your submission. Please re-enter") + print("User not found. Please Try again") return None #did not create account through website, has to signup/login @@ -68,7 +72,7 @@ def signup(): { 'type': 'input', 'name': 'webmail', - 'message': 'What\'s TJ Webmail?', + 'message': 'What\'s your TJ Webmail?', }, { 'type': 'password', @@ -77,6 +81,19 @@ def signup(): }, ] user = prompt(questions) + for i in user: + if user[i] == "": + print("Some forms were left blank. Try again.\n") + return + if len(user["password"]) < 6: + print("Password is too short. Try again.") + return + if (("@tjhsst.edu" in user['webmail']) == False): + print("Webmail entered was not a @tjhhsst.edu. Try again.") + return + + print("@tjhsst.edu" in user['webmail'] == False) + user["classes"] = [] with open('users.json', 'r') as json_file: data = json.load(json_file) @@ -91,7 +108,6 @@ def setup(user): for a in user["classes"][c]: os.makedirs(c + "/" + a) - def start(): if(os.path.exists(".login.txt") == True): b = yesorno("Do you have a SkoolOS account?(y/N)") diff --git a/run.py b/run.py index 2bac134..aca8859 100644 --- a/run.py +++ b/run.py @@ -1,6 +1,6 @@ from __future__ import print_function, unicode_literals from PyInquirer import prompt, print_json -from commands import start +from commands import start, update import argparse import json import os @@ -10,6 +10,7 @@ my_parser = argparse.ArgumentParser(prog='skool', description='Let SkoolOS contr my_parser.add_argument('--init', action="store_true") #returns true if run argument args = my_parser.parse_args() +update() outputs = vars(args) if(outputs['init']): start()