Advertisement
Guest User

userAdmin.py

a guest
Oct 13th, 2018
1,858
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. # Administrator accounts list
  2. adminList = [
  3. {
  4. "username": "DaBigBoss",
  5. "password": "DaBest"
  6. },
  7. {
  8. "username": "root",
  9. "password": "toor"
  10. }
  11. ]
  12.  
  13. # Build your login functions below
  14.  
  15. def checkLogin(userInfo, adminList):
  16. #look through adminList for a match with userInfo
  17. for user in adminList:
  18. #if userInfo matches current user
  19. if user['username'] == userInfo['username'] and user['password'] == userInfo['password']:
  20. return True
  21. return False
  22.  
  23.  
  24. def getCreds():
  25. #ask for username and password
  26. username = input("enter username: ")
  27. password = input("enter password: ")
  28. return {"username": username, "password": password}
  29.  
  30.  
  31. loggedin = False
  32.  
  33. #while the user is not logged in (logged in is false
  34.  
  35. while loggedin == False:
  36. #save the credentials
  37. userInfo = getCreds()
  38. #check and save the credentials in loggedin
  39. loggedin = checkLogin(userInfo, adminList)
  40. print("---------")
  41. #if credentials is false
  42. if loggedin == False
  43. #tell user to try again
  44. print("wrong try again! ")
  45. #you logged in yayayay
  46. print("YOU HAVE LOGGED IN!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement