Advertisement
WhineyMonkey10

Untitled

Nov 28th, 2022
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. class admin:
  2. def delete(username, response):
  3. response = response
  4. response.configure(text="Deleting user...")
  5. response.update()
  6. time.sleep(1)
  7. username = username
  8.  
  9. if username == "admin":
  10. response.configure(text="Cannot delete admin account.")
  11. response.update()
  12.  
  13. else:
  14. response.configure(text="Connecting to database...")
  15. response.update()
  16. time.sleep(0.5)
  17.  
  18. load_dotenv()
  19. connectionstring = os.getenv('MONGODB')
  20. print(connectionstring)
  21. client = MongoClient(connectionstring)
  22. dbname = "cookiehacks"
  23. collection = "credentials"
  24. print("Connected to database.")
  25.  
  26. if username in client[dbname][collection].find_one({"username": username}):
  27. print("User found.")
  28. response.configure(text="Deleting user...")
  29. response.update()
  30. time.sleep(0.5)
  31. client[dbname][collection].delete_one({"username": username})
  32. print("User deleted.")
  33. response.configure(text="User deleted.")
  34. response.update()
  35. time.sleep(0.5)
  36. response.configure(text="Done.")
  37. response.update()
  38.  
  39. else:
  40. response.configure(text="User not found.")
  41. response.update()
  42. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement