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 = """