Guest User

Untitled

a guest
Dec 13th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. from tkinter import *
  2. from tkinter import ttk
  3.  
  4. root = tkinter.Tk()
  5. root.geometry("800x600")
  6. root.wm_title("Registration Form")
  7.  
  8.  
  9. users = {"root": {
  10. "password": "dean",
  11. "group": "admin"}}
  12.  
  13.  
  14. def validate(form):
  15. if len(form) > 0:
  16. return False
  17. return True
  18.  
  19.  
  20. def authorize(username, password):
  21. if username in users:
  22. if password == users[username]["password"]:
  23. print("Login Successful!")
  24. return True
  25. return False
  26.  
  27.  
  28. def signin():
  29. while True:
  30. username = input("Username: ")
  31. if not len(username) > 0:
  32. print("Username can't be blank")
  33. else:
  34. break
  35. while True:
  36. password = input("Password: ")
  37. if not len(password) > 0:
  38. print("Password can't be blank")
  39. else:
  40. break
  41.  
  42. if authorize(username, password):
  43. print("Welcome to the System.")
  44. else:
  45. print("Invalid username or password")
  46.  
  47.  
  48. def signup():
  49. while True:
  50. username = input("New username: ")
  51. if not len(username) > 0:
  52. print("Username can't be blank")
  53. continue
  54. else:
  55. break
  56. while True:
  57. password = input("New password: ")
  58. if not len(password) > 0:
  59. print("Password can't be blank")
  60. continue
  61. else:
  62. break
  63. users[username] = {}
  64. users[username]["password"] = password
  65. users[username]["group"] = "user"
  66. print("Account has been created")
  67.  
  68.  
  69. while True:
  70. option = input("> ")
  71. if option == "login":
  72. signin()
  73. elif option == "register":
  74. signup()
  75. elif option == "exit":
  76. break
  77. else:
  78. print(option + " is not an option")
Add Comment
Please, Sign In to add comment