Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class User:
- def info_save(self, save_username_1, save_password_1):
- u_input = UserInput()
- if (save_password_1 and save_username_1) != "":
- file_read = open("user_list.txt")
- delimiter = ","
- data = {}
- for line in file_read.readlines():
- a = line.strip().split(delimiter)
- if len(a) == 2:
- data[a[0]] = a[1]
- file_read.close()
- if save_username_1 in data:
- print("USERNAME is already in use", "\n")
- u_input.register()
- else:
- file_write = open("user_list.txt", "a")
- file_write.write(save_username_1 + "," + save_password_1 + "\n")
- file_write.close()
- print("your account has been saved", "\n")
- else:
- print("invalid USERNAME or PASSWORD", "\n")
- u_input.register()
- class Control:
- def user_control(self, username_input, password_input, counter):
- u_input = UserInput()
- if counter != 0:
- if (username_input and password_input) != "":
- file = open("user_list.txt")
- delimiter = ","
- data = {}
- for line in file.readlines():
- a = line.strip().split(delimiter)
- if len(a) == 2:
- data[a[0]] = a[1]
- if username_input in data:
- password = data[username_input]
- if password == password_input:
- print("ACCESS")
- # add
- else:
- print("wrong password")
- print("you have", counter, "tries Left")
- counter -= 1
- u_input.login(i=counter)
- else:
- print("USERNAME ist not in existence please try to REGISTER", "\n")
- u_input.login(i=counter)
- else:
- print("invalid PASSWORD or USERNAME", "\n")
- u_input.login(i=counter)
- else:
- print("ACCESS DENIED")
- class UserInput:
- def register(self):
- main_save = User()
- main_save.info_save(save_username_1=input("insert username: "),
- save_password_1=input("insert password: "))
- def login(self, i):
- main_control = Control()
- main_control.user_control(username_input=input("insert your username: "),
- password_input=input("insert your password: "),
- counter=i)
- class Main:
- def start(self):
- input_main = ""
- reg = UserInput()
- input_main = input("type R for REGISTER or L for LOGIN: ")
- if input_main == "R" or input_main == "r":
- success_main = "true"
- print("\n")
- reg.register()
- if input_main == "L" or input_main == "l":
- print("\n")
- reg.login(i=2)
- else:
- entry = Main()
- entry.start()
- # entry point
- Entry = Main()
- Entry.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement