def logincred(self): style = style_from_dict({ Token.QuestionMark: '#E91E63 bold', Token.Selected: '#00FFFF', Token.Instruction: '', Token.Answer: '#2196f3 bold', Token.Question: '#7FFF00 bold', }) time.sleep(0.2) questions = [{ 'type': 'list', 'name': 'log', 'message': 'Choose one :', 'choices': ['login', 'registration'], 'default': 'login' }] answers = prompt(questions, style=style) self.clear() time.sleep(0.05) print("") ######################################################### suffix = '%(index)d/%(max)d [%(elapsed)d / %(eta)d / %(eta_td)s]' bar = FillingCirclesBar(" connecting to TCN server ", suffix=suffix) for i in bar.iter(range(100)): self.sleep() ######################################################### time.sleep(1.0) os.system("cls") colour.prGreen("connected") time.sleep(0.5) self.clear() colour.prGreen("=================") colour.prGreen("|| LOGIN ||") colour.prGreen("=================") print(" ") user1 = dict() temp_data = login_auth_reg.searchuser_password() for i in range(len(temp_data)): user1[temp_data[i][0]] = temp_data[i][1] self.users = user1 if answers['log'] == 'login': username = input(" username: "******" password: "******"") ############################################# a = 0 s = "." sys.stdout.write(' please wait ') while a <= 10: sys.stdout.write(s) sys.stdout.flush() time.sleep(0.3) a = a + 1 ############################################## print("") time.sleep(0.67) if username in self.users: if self.users[username] == password: self.user = username print("") cprint(" logged in successfully", "cyan") time.sleep(1) else: cprint(" incorrect password", "red") print(" ") time.sleep(0.56) self.clear() self.logincred() else: cprint(" incorrect username", "red") print("") time.sleep(0.56) self.clear() self.logincred() elif answers["log"] == "registration": name = input(" name: ") username = input(" username: "******" password: "******"q", "@", "%", "w", "r", "g", "hg", "crate", "traitor", "aligator", "unknw", "@@@@@", "&&&&", "###" ]) + username checker = login_auth_reg.register(uniqid, name, username, password) time.sleep(0.95) cprint(" registration successfull", "yellow") time.sleep(1) self.logincred()
def logincred(self): style = style_from_dict({ Token.QuestionMark: '#E91E63 bold', Token.Selected: '#00FFFF', Token.Instruction: '', Token.Answer: '#2196f3 bold', Token.Question: '#7FFF00 bold', }) #Using PyInquirer for Dropdown menu interface time.sleep(0.2) questions = [{ 'type': 'list', 'name': 'log', 'message': 'Choose one :', 'choices': ['login', 'registration'], 'default': 'login' }] answers = prompt(questions, style=style) #Loading bar animation os.system('clear') time.sleep(0.05) print("") ######################################################### suffix = '%(index)d/%(max)d [%(elapsed)d / %(eta)d / %(eta_td)s]' bar = FillingCirclesBar(" loading ", suffix=suffix) for i in bar.iter(range(100)): self.sleep() ######################################################### time.sleep(1.0) os.system("clear") cprint("Connected...", "green", attrs=['bold']) time.sleep(0.5) os.system('clear') #get user data from database user1 = dict() temp_data = user_login_auth.find_user() for i in temp_data: user1[i[0]] = i[1] self.users = user1 if answers['log'] == 'login': username = input(" username: "******" password: "******"") #check if user is in database if username in self.users: #check password if self.users[username] == password: self.user = username cprint(" logged in successfullly", "cyan", attrs=['bold']) time.sleep(1) else: cprint("Incorrect password", "red") print("") time.sleep(0.5) os.system('clear') self.logincred() else: cprint("Incorrect username!", "red") print("") time.sleep(0.5) os.system('clear') self.logincred() elif answers["log"] == "registration": user_login_auth.register() cprint("Registered Successfully!", "yellow", attrs=['bold']) time.sleep(1) self.logincred()