Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def login():
- creds = 'credfile.tmp'
- userOption = input("Do you own an account? Please type yes or no.")
- if userOption == "yes":
- try:
- usersfile = open(creds, 'r')
- users = {}
- for l in usersfile:
- lsplit = l.split(";")
- users[lsplit[0]] = lsplit[1]
- print("Please login.\n")
- user = input('Enter username: ')
- passwd = input('Enter password: ')
- if (user, passwd) in users.items():
- print('\n[+] Logged In\n')
- # SUCCESS DO SOMETHING
- return True
- else:
- print("Wrong Username or Password")
- return False
- except:
- print("No users")
- return False
- elif userOption == "no":
- name=input("Enter your first name : ")
- age=int(input("Enter your age : "))
- yearGroup=input("Enter your year group : ")
- newUser = name[:3]+str(age)
- print("Your username will be, " + newUser)
- newPassw=input("Please enter a password for your account. (Minimum 6 characters long) : ")
- if len(newPassw) < 6:
- print("Password length is too short!")
- return False
- with open(creds, 'a')as f:
- f.write(newUser + ";" + newPassw)
- print("You have successfully created your account!")
- return False
- while True:
- login()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement