Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def enterDetails(users, passwords):
- #Another definition
- global enterUser
- #Another global variable
- userAlready = messagebox.askyesno("Account?","Do you already have an account?")
- #Creates a message box asking if they have got an account, returning a boolean
- if userAlready == True:
- #If the user presses 'Yes'...
- enterUser = input("Enter your username\n> ").lower()
- #Gets the username and puts it in lower case
- if enterUser in users:
- #if the user is in the users.txt document...
- enterPass = str(input("Enter your password\n> "))
- #Gets the password
- userPos = users.index(enterUser)
- #Creates a variable and stores the number of lines in users
- if enterPass in passwords:
- #if the passwrod entered is in pass.txt...
- passPos = passwords.index(enterPass)
- #indexes the passwords
- if userPos == passPos:
- #if the 2 numbers are the same
- print ("You have successfully logged in", enterUser)
- time.sleep(5)
- clear()
- #log them in
- return True
- #moves on to the next definition
- else:
- #else...
- print("You have entered the wrong password, please try again!")
- #if the password was wrong, ask them to re enter the user and password and restarts program
- time.sleep(5)
- clear()
- else:
- #else...
- print("We couldn't find your password, please try again!")
- #if the password isn't in pass.txt, ask them to re enter user and password and resets program
- time.sleep(5)
- clear()
- else:
- #else...
- retryUser = messagebox.askyesno("Retry?","We couldn't find your username, would you like to retry?")
- #asks them if they want to try another username
- if retryUser == True:
- #if they do...
- i = 0
- #returns i as 0, restarting the loop
- time.sleep(5)
- clear()
- else:
- #else...
- quit()
- #it quits the program
- return False
- #returns false (I believe this is obselete)
- else:
- #else if they don't have a user
- file = open('users.txt','a')
- #open users.txt as 'amend'
- newUser = input("Please enter username\n").lower()
- #asks for a new username and puts it in lower case
- file.write("\n" + newUser)
- #writes the new user on a new line
- file.close()
- #closes the file
- f = 0
- #defines f as 0
- while f == 0:
- #creates a loop
- file = open('pass.txt','a')
- #opens pass.txt as 'amend'
- newPass = input("Please enter password\n")
- #asks for a new password
- confirmPass = input("Please confirm password\n")
- #asks for comformation
- if newPass == confirmPass:
- #if they are the same...
- file.write("\n" + newPass)
- #write the password to the file
- file.close()
- #close the file
- print("New user created! Please restart the program and log in with your credidentials")
- #prints text
- quit()
- #quits the program
- else:
- #else...
- print("Passwords didn't match, please try again or use a different password.")
- #tells them the passwords don't match and restarts the password loop
- f == 0
- time.sleep(5)
- clear()
- #sets f to 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement