From ab87f5a7f1c9af960ab72428b93e05dd2ab593fa Mon Sep 17 00:00:00 2001 From: HelloZeroNet Date: Sun, 19 Apr 2015 15:43:10 +0200 Subject: [PATCH] Remove accidently duplicated multiuser plugin --- plugins/Multiuser/MultiuserPlugin.py | 169 --------------------------- plugins/Multiuser/__init__.py | 1 - src/Config.py | 2 +- 3 files changed, 1 insertion(+), 171 deletions(-) delete mode 100644 plugins/Multiuser/MultiuserPlugin.py delete mode 100644 plugins/Multiuser/__init__.py diff --git a/plugins/Multiuser/MultiuserPlugin.py b/plugins/Multiuser/MultiuserPlugin.py deleted file mode 100644 index 850a0995..00000000 --- a/plugins/Multiuser/MultiuserPlugin.py +++ /dev/null @@ -1,169 +0,0 @@ -import re, time, sys -from Plugin import PluginManager -from Crypt import CryptBitcoin - -@PluginManager.registerTo("UiRequest") -class UiRequestPlugin(object): - def __init__(self, *args, **kwargs): - self.user_manager = sys.modules["User.UserManager"].user_manager - super(UiRequestPlugin, self).__init__(*args, **kwargs) - - - # Create new user and inject user welcome message if necessary - # Return: Html body also containing the injection - def actionWrapper(self, path): - user_created = False - user = self.getCurrentUser() # Get user from cookie - - if not user: # No user found by cookie - user = self.user_manager.create() - user_created = True - - master_address = user.master_address - master_seed = user.master_seed - - if user_created: - extra_headers = [('Set-Cookie', "master_address=%s;path=/;max-age=2592000;" % user.master_address)] # Max age = 30 days - else: - extra_headers = [] - - loggedin = self.get.get("login") == "done" - - back = super(UiRequestPlugin, self).actionWrapper(path, extra_headers) # Get the wrapper frame output - - if not user_created and not loggedin: return back # No injection necessary - - if not back or not hasattr(back, "endswith"): return back # Wrapper error or not string returned, injection not possible - - if user_created: - # Inject the welcome message - inject_html = """ - - - - - - """.replace("\t", "") - inject_html = inject_html.replace("{master_seed}", master_seed) # Set the master seed in the message - - back = re.sub("\s*\s*$", inject_html, back) # Replace the tags with the injection - - elif loggedin: - inject_html = """ - - - - - """.replace("\t", "") - back = re.sub("\s*\s*$", inject_html, back) # Replace the tags with the injection - - return back - - - # Get the current user based on request's cookies - # Return: User object or None if no match - def getCurrentUser(self): - cookies = self.getCookies() - user_manager = self.user_manager - user = None - if "master_address" in cookies: - users = self.user_manager.list() - user = users.get(cookies["master_address"]) - return user - - -@PluginManager.registerTo("UserManager") -class UserManagerPlugin(object): - # In multiuser mode do not load the users - def load(self): - if not self.users: self.users = {} - return self.users - - - # Find user by master address - # Return: User or None - def get(self, master_address=None): - users = self.list() - if master_address in users: - user = users[master_address] - else: - user = None - return user - - -@PluginManager.registerTo("User") -class UserPlugin(object): - # In multiuser mode users data only exits in memory, dont write to data/user.json - def save(self): - return False - - -@PluginManager.registerTo("UiWebsocket") -class UiWebsocketPlugin(object): - # Let the page know we running in multiuser mode - def formatServerInfo(self): - server_info = super(UiWebsocketPlugin, self).formatServerInfo() - server_info["multiuser"] = True - if "ADMIN" in self.site.settings["permissions"]: - server_info["master_address"] = self.user.master_address - return server_info - - - # Show current user's master seed - def actionUserShowMasterSeed(self, to): - if not "ADMIN" in self.site.settings["permissions"]: return self.response(to, "Show master seed not allowed") - message = "Your unique private key:" - message+= "
%s
" % self.user.master_seed - message+= "(Save it, you can access your account using this information)" - self.cmd("notification", ["info", message]) - - - # Logout user - def actionUserLogout(self, to): - if not "ADMIN" in self.site.settings["permissions"]: return self.response(to, "Logout not allowed") - message = "You have been logged out. Login to another account" - message+= "" - self.cmd("notification", ["done", message, 1000000]) # 1000000 = Show ~forever :) - # Delete from user_manager - user_manager = sys.modules["User.UserManager"].user_manager - if self.user.master_address in user_manager.users: - del user_manager.users[self.user.master_address] - self.response(to, "Successful logout") - else: - self.response(to, "User not found") - - - # Show login form - def actionUserLoginForm(self, to): - self.cmd("prompt", ["Login
Your private key:", "password", "Login"], self.responseUserLogin) - - - # Login form submit - def responseUserLogin(self, master_seed): - user_manager = sys.modules["User.UserManager"].user_manager - user = user_manager.create(master_seed=master_seed) - if user.master_address: - message = "Successfull login, reloading page..." - message+= "" % user.master_address - message+= "" - self.cmd("notification", ["done", message]) - else: - self.cmd("notification", ["error", "Error: Invalid master seed"]) - self.actionUserLoginForm(0) - diff --git a/plugins/Multiuser/__init__.py b/plugins/Multiuser/__init__.py deleted file mode 100644 index 154d6008..00000000 --- a/plugins/Multiuser/__init__.py +++ /dev/null @@ -1 +0,0 @@ -import MultiuserPlugin diff --git a/src/Config.py b/src/Config.py index b5edd501..fb7a3583 100644 --- a/src/Config.py +++ b/src/Config.py @@ -4,7 +4,7 @@ import ConfigParser class Config(object): def __init__(self): self.version = "0.2.9" - self.rev = 106 + self.rev = 107 self.parser = self.createArguments() argv = sys.argv[:] # Copy command line arguments argv = self.parseConfig(argv) # Add arguments from config file