# LOGIN CLIENT # HANDLES ACCOUNT CREATION AND VERIFICATION # user validity check: no spaces no slashes no unprintable ASCII characters no carriage returns or anything like that from pathlib import Path from datetime import datetime import time # Sets the universal current path script_dir = Path(__file__).parent def login_logic(): while True: print("LOGIN CLIENT") print("[1] Login [2] Sign in") login_choice = input(" > ") if login_choice == "1": while True: login_username = input("Username > ") if login_username.isalnum(): break else: print("Your username contains spaces or symbols! Check again.") while True: login_password = input("Password > ") if login_password.isalnum(): break else: print("Only 1-9, A-Z and a-z are allowed!") # Get current time (request identifier) timestamp_ms = int(time.time() * 1000) # Create a request with open(script_dir / "requests" / f"{timestamp_ms}.txt", "w") as request: request.write(f"LOGIN:{login_username}:{login_password}") # TODO WAIT FOR SUCCESS/UNSUCCESS MESSAGE if login_choice == "2": while True: signup_username = input("New Username > ") if signup_username.isalnum(): break else: print("Cannot include spaces or symbols!") while True: while True: signup_password = input("Password > ") if signup_password.isalnum(): break else: print("Only 1-9, A-Z and a-z are allowed!") while True: signup_password_rep = input("Repeat Password > ") if signup_password_rep.isalnum(): break else: print("Only 1-9, A-Z and a-z are allowed!") if signup_password == signup_password_rep: break else: print("Passwords are not the same!") # Get current time (request identifier) timestamp_ms = int(time.time() * 1000) with open(script_dir / "requests" / f"{timestamp_ms}.txt", "w") as request: request.write(f"CREATEUSER:{signup_username}:{signup_password}") # TODO WAIT FOR SUCCESS/UNSUCCESS MESSAGE # The main thing if __name__ == "__main__": login_logic()