Use injectScript for Multiuser plugin notification
This commit is contained in:
parent
dace0671c2
commit
a98c465c9a
1 changed files with 23 additions and 8 deletions
|
@ -128,9 +128,12 @@ class UiWebsocketPlugin(object):
|
||||||
def actionUserLogout(self, to):
|
def actionUserLogout(self, to):
|
||||||
if "ADMIN" not in self.site.settings["permissions"]:
|
if "ADMIN" not in self.site.settings["permissions"]:
|
||||||
return self.response(to, "Logout not allowed")
|
return self.response(to, "Logout not allowed")
|
||||||
message = "<b>You have been logged out.</b> <a href='#Login' class='button' onclick='zeroframe.cmd(\"userLoginForm\", []); return false'>Login to another account</a>"
|
message = "<b>You have been logged out.</b> <a href='#Login' class='button' id='button_notification'>Login to another account</a>"
|
||||||
message += "<script>document.cookie = 'master_address=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/'</script>"
|
|
||||||
self.cmd("notification", ["done", message, 1000000]) # 1000000 = Show ~forever :)
|
self.cmd("notification", ["done", message, 1000000]) # 1000000 = Show ~forever :)
|
||||||
|
|
||||||
|
script = "document.cookie = 'master_address=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/';"
|
||||||
|
script += "$('#button_notification').on('click', function() { zeroframe.cmd(\"userLoginForm\", []); });"
|
||||||
|
self.cmd("injectScript", script)
|
||||||
# Delete from user_manager
|
# Delete from user_manager
|
||||||
user_manager = sys.modules["User.UserManager"].user_manager
|
user_manager = sys.modules["User.UserManager"].user_manager
|
||||||
if self.user.master_address in user_manager.users:
|
if self.user.master_address in user_manager.users:
|
||||||
|
@ -151,10 +154,10 @@ class UiWebsocketPlugin(object):
|
||||||
if not user:
|
if not user:
|
||||||
user = user_manager.create(master_seed=master_seed)
|
user = user_manager.create(master_seed=master_seed)
|
||||||
if user.master_address:
|
if user.master_address:
|
||||||
message = "Successfull login, reloading page..."
|
script = "document.cookie = 'master_address=%s;path=/;max-age=2592000;';" % user.master_address
|
||||||
message += "<script>document.cookie = 'master_address=%s;path=/;max-age=2592000;'</script>" % user.master_address
|
script += "zeroframe.cmd('wrapperReload', ['login=done']);"
|
||||||
message += "<script>zeroframe.cmd('wrapperReload', ['login=done'])</script>"
|
self.cmd("notification", ["done", "Successfull login, reloading page..."])
|
||||||
self.cmd("notification", ["done", message])
|
self.cmd("injectScript", script)
|
||||||
else:
|
else:
|
||||||
self.cmd("notification", ["error", "Error: Invalid master seed"])
|
self.cmd("notification", ["error", "Error: Invalid master seed"])
|
||||||
self.actionUserLoginForm(0)
|
self.actionUserLoginForm(0)
|
||||||
|
@ -178,9 +181,9 @@ class UiWebsocketPlugin(object):
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<b>Hello, welcome to ZeroProxy!</b><div style='margin-top: 8px'>A new, unique account created for you:</div>
|
<b>Hello, welcome to ZeroProxy!</b><div style='margin-top: 8px'>A new, unique account created for you:</div>
|
||||||
<input type='text' class='masterseed' onclick='this.value = "{master_seed}"; this.setSelectionRange(0,100);' value='Click here to show' readonly/>
|
<input type='text' class='masterseed' id='button_notification_masterseed' value='Click here to show' readonly/>
|
||||||
<div style='text-align: center; font-size: 85%; margin-bottom: 10px;'>
|
<div style='text-align: center; font-size: 85%; margin-bottom: 10px;'>
|
||||||
or <a href='#Download' onmousedown='this.href = window.URL.createObjectURL(new Blob(["ZeroNet user master seed:\\r\\n{master_seed}"]))'
|
or <a href='#Download' id='button_notification_download'
|
||||||
class='masterseed_download' download='zeronet_private_key.backup'>Download backup as text file</a>
|
class='masterseed_download' download='zeronet_private_key.backup'>Download backup as text file</a>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
@ -191,8 +194,20 @@ class UiWebsocketPlugin(object):
|
||||||
<small>This site allows you to browse ZeroNet content, but if you want to secure your account <br>
|
<small>This site allows you to browse ZeroNet content, but if you want to secure your account <br>
|
||||||
and help to keep the network alive, then please run your own <a href='https://zeronet.io' target='_blank'>ZeroNet client</a>.</small>
|
and help to keep the network alive, then please run your own <a href='https://zeronet.io' target='_blank'>ZeroNet client</a>.</small>
|
||||||
""".replace("{master_seed}", master_seed)
|
""".replace("{master_seed}", master_seed)
|
||||||
|
|
||||||
self.cmd("notification", ["info", message])
|
self.cmd("notification", ["info", message])
|
||||||
|
|
||||||
|
script = """
|
||||||
|
$("#button_notification_masterseed").on("click", function() {
|
||||||
|
this.value = "{master_seed}"; this.setSelectionRange(0,100);
|
||||||
|
})
|
||||||
|
$("#button_notification_download").on("mousedown", function() {
|
||||||
|
this.href = window.URL.createObjectURL(new Blob(["ZeroNet user master seed:\\r\\n{master_seed}"]))
|
||||||
|
})
|
||||||
|
""".replace("{master_seed}", master_seed)
|
||||||
|
self.cmd("injectScript", script)
|
||||||
|
|
||||||
|
|
||||||
def actionPermissionAdd(self, to, permission):
|
def actionPermissionAdd(self, to, permission):
|
||||||
if permission == "NOSANDBOX":
|
if permission == "NOSANDBOX":
|
||||||
self.cmd("notification", ["info", "You can't disable sandbox on this proxy!"])
|
self.cmd("notification", ["info", "You can't disable sandbox on this proxy!"])
|
||||||
|
|
Loading…
Reference in a new issue