Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def CreateUser():
- username, password1, password2 = "", "", "", ""
- while True:
- username = input("\nPlease enter the username of the new user: ")
- if username == "-1":
- mainMenu()
- if len(username) >10:
- print("\nUsername must be less than 11 characters.\n")
- elif username.isalpha() == False:
- print("\nThe username must only contain alpha.\n")
- else:
- break
- while True:
- password1 = input("\nPlease enter the password for the user: ")
- if password1 == "-1":
- mainMenu()
- if len(password1) > 10:
- print("\nPassword must be less than 11 characters.\n")
- password2 = input("\nPlease enter the password again: ")
- if password2 == "-1":
- mainMenu()
- if len(password2) > 10:
- print("\nPassword must be less than 11 characters.\n")
- if password1 != password2:
- print("\nPasswords do not match.\n")
- else:
- break
- username = username.lower()
- password1 = password1.lower()
- password2 = password2.lower()
- usernameStore = username.ljust(10)
- passwordStore = password1.ljust(10)
- f = open("users.txt","a")
- iStore = usernameStore + passwordStore + "\n"
- f.write(iStore)
- f.close()
- print("\nNew User Created: ")
- def CreateFiles():
- f = open("users.txt","w+")
- print("user file created")
- f = open("passwords.txt","w+")
- print("password file created")
- f = open("customerID.txt","w+")
- print("customerID file created")
- f = open("stockID.txt","w+")
- print("stockID file created")
- f = open("customerID.txt","w+")
- print("customerID file created")
- f = open("customerID.txt","w+")
- print("customerID file created")
- f = open("invoiceID.txt","w+")
- print("invoiceID file created")
- CreateFiles()
- def ValidateUserType():
- validateUserType = ""
- validateUsername = ""
- validatePassword = ""
- username = str(input("\nPlease enter your username: \n"))
- password = str(input("\nPlease enter your password: \n"))
- while True:
- try:
- f = open("users.txt","r")
- validateCounter = 0
- while True:
- location = f.readline()
- validateUserType = location[20:22]
- validateUserType = validateUserType.strip()
- validateUsername = location [0:10]
- validateUsername = validateUsername.strip()
- validateUsername = validateUsername.lower()
- username = username.lower()
- validatePassword = location[10:20]
- validatePassword = validatePassword.strip()
- validatePassword = validatePassword.lower()
- password = password.lower()
- if location == "":
- f.close()
- break
- if validateUserType == str(1) and validateUsername == username and validatePassword == password:
- validateCounter = validateCounter + 1
- adminMenu()
- break
- if validateUserType == str(2) and validateUsername == username and validatePassword == password:
- validateCounter = validateCounter + 1
- userMenu()
- break
- if validateCounter ==0:
- print("\nNo user in the file with those login details. \n")
- ValidateUserType()
- except FileNotFoundError:
- print("There is no Users file for you to search!\n")
- CreateUser()
- ValidateUserType()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement