UserPlugin.py 994 B

123456789101112131415161718192021222324252627282930313233343536
  1. from Config import config
  2. from Plugin import PluginManager
  3. allow_reload = False
  4. @PluginManager.registerTo("UserManager")
  5. class UserManagerPlugin(object):
  6. def load(self):
  7. if not config.multiuser_local:
  8. # In multiuser mode do not load the users
  9. if not self.users:
  10. self.users = {}
  11. return self.users
  12. else:
  13. return super(UserManagerPlugin, self).load()
  14. # Find user by master address
  15. # Return: User or None
  16. def get(self, master_address=None):
  17. users = self.list()
  18. if master_address in users:
  19. user = users[master_address]
  20. else:
  21. user = None
  22. return user
  23. @PluginManager.registerTo("User")
  24. class UserPlugin(object):
  25. # In multiuser mode users data only exits in memory, dont write to data/user.json
  26. def save(self):
  27. if not config.multiuser_local:
  28. return False
  29. else:
  30. return super(UserPlugin, self).save()