Sep-08-2019, 09:00 AM
print("Welcome to project Apollo!") time.sleep(0.5) RegQ = True while RegQ: RegLR = input("Do you want to login or register: ") if RegLR.lower() == "register": print("Please use the register app provided!") time.sleep(3) continue elif RegLR.lower() == "login": print("Welcome to Login manager!") time.sleep(1) break else: print("Unknown input!") time.sleep(2) continue LoginBegin = True while LoginBegin: ForgotPass = input("Have you forgotten your password?: ") if ForgotPass.lower() == "no" or "n": print("Please login:") Username = input("Enter Username: ") Password = input("Enter Password: ") elif ForgotPass.lower() == "yes" or "y": __forgotpass__() else: print("Unknown input!") continueSomehow this code is not working.
The do you want to login works but the i get to the Forgotpass input. Whatever I type in the input "Have you forgotten your password?: " It will always :
print("Please login:")
Username = input("Enter Username: ")
Password = input("Enter Password: ")
If I type yes it will still do it and if I type a random string it will still do it. Sorry this may be a bit confusing but it is hard to explain. if you need me to explain anything else please tell me.
Code for the __forgotpass__:
def __forgotpass__(): Email = input("Please enter your email: ") path = pathlib.Path(f'B:\\Other\\python\\Secret\\Emails\\{Email}.txt') if path.exists() == False: print("Email does not have an account!") time.sleep(3) if path.exists() == True: print("Email Found!") time.sleep(0.5) Retrieveaccount = input("Do you want to retrieve the account?: ") if Retrieveaccount.lower() == "no" or "n": exit() elif Retrieveaccount.lower() == "yes" or "y": Code = randint(1000, 9999) sender_email = "[email protected]" receiver_email = Email port = 465 password = "Benjamin123456789\"" context = ssl.create_default_context() message = f"""\ Subject: Hi there Your code is: {Code}""" with smtplib.SMTP_SSL("smtp.gmail.com", port, context=context) as server: server.login("[email protected]", password) server.sendmail(sender_email, receiver_email, message) EmailSent = True while EmailSent: print("Check your email for code") print(""" Press 1 if you have recieved the email Press 2 if you have not recieved the email """) EmailRec = input("") if int(EmailRec) == 2: Email = input("Re-enter your email: ") receiver_email = Email with smtplib.SMTP_SSL("smtp.gmail.com", port, context=context) as server: server.login("[email protected]", password) server.sendmail(sender_email, receiver_email, message) continue if int(EmailRec) == 1: Codeinp = input("EnterCode: ") if Codeinp == str(Code): break if Codeinp != str(Code): print("Code does not match!") time.sleep(1) continue PassQ = True while PassQ: Newpasswordtry = input("New password: ") ConfirmNewPassword = input("Confirm password: ") if Newpasswordtry != ConfirmNewPassword: print("password does not match!") time.sleep(1) continue if Newpasswordtry == ConfirmNewPassword: print("Changing Password...") EmailsFolder = "B:\\Other\\python\\Secret\\Emails\\" file_to_open = EmailsFolder + f"{Email}.txt" f = open(file_to_open, "r") UsernameEmail = f.read() f.close() with open(f"B:\\Other\\python\\Secret\\Accounts\\{UsernameEmail}.txt", 'r') as f: text = f.read() f.close() pw = text.partition("password:\n")[2].partition("\nemail:")[0] newpassword = ConfirmNewPassword newtext = text.replace(pw, newpassword) with open(f"B:\\Other\\python\\Secret\\Accounts\\{UsernameEmail}.txt", 'w') as f: f.write(newtext) f.close