Rev989, Save users file on newsfeed follow, Local mode in Multiuser plugin to disable restrication and save users data to disk
This commit is contained in:
parent
0897154584
commit
ed0e858e30
4 changed files with 75 additions and 34 deletions
|
@ -5,6 +5,7 @@ import re, time
|
|||
class UiWebsocketPlugin(object):
|
||||
def actionFeedFollow(self, to, feeds):
|
||||
self.user.setFeedFollow(self.site.address, feeds)
|
||||
self.user.save()
|
||||
self.response(to, "ok")
|
||||
|
||||
def actionFeedListFollow(self, to):
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
import re
|
||||
import sys
|
||||
|
||||
from Config import config
|
||||
from Plugin import PluginManager
|
||||
from Crypt import CryptBitcoin
|
||||
import UserPlugin
|
||||
|
||||
|
||||
@PluginManager.registerTo("UiRequest")
|
||||
|
@ -93,32 +97,6 @@ class UiRequestPlugin(object):
|
|||
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
|
||||
|
@ -148,7 +126,8 @@ class UiWebsocketPlugin(object):
|
|||
# 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]
|
||||
if not config.multiuser_local:
|
||||
del user_manager.users[self.user.master_address]
|
||||
self.response(to, "Successful logout")
|
||||
else:
|
||||
self.response(to, "User not found")
|
||||
|
@ -160,7 +139,9 @@ class UiWebsocketPlugin(object):
|
|||
# Login form submit
|
||||
def responseUserLogin(self, master_seed):
|
||||
user_manager = sys.modules["User.UserManager"].user_manager
|
||||
user = user_manager.create(master_seed=master_seed)
|
||||
user = user_manager.get(CryptBitcoin.privatekeyToAddress(master_seed))
|
||||
if not user:
|
||||
user = user_manager.create(master_seed=master_seed)
|
||||
if user.master_address:
|
||||
message = "Successfull login, reloading page..."
|
||||
message += "<script>document.cookie = 'master_address=%s;path=/;max-age=2592000;'</script>" % user.master_address
|
||||
|
@ -172,16 +153,40 @@ class UiWebsocketPlugin(object):
|
|||
|
||||
# Disable not Multiuser safe functions
|
||||
def actionSiteDelete(self, to, *args, **kwargs):
|
||||
self.cmd("notification", ["info", "This function is disabled on this proxy"])
|
||||
if not config.multiuser_local:
|
||||
self.cmd("notification", ["info", "This function is disabled on this proxy"])
|
||||
else:
|
||||
return super(UiWebsocketPlugin, self).actionSiteDelete(to, *args, **kwargs)
|
||||
|
||||
def actionConfigSet(self, to, *args, **kwargs):
|
||||
self.cmd("notification", ["info", "This function is disabled on this proxy"])
|
||||
if not config.multiuser_local:
|
||||
self.cmd("notification", ["info", "This function is disabled on this proxy"])
|
||||
else:
|
||||
return super(UiWebsocketPlugin, self).actionConfigSet(to, *args, **kwargs)
|
||||
|
||||
def actionServerShutdown(self, to, *args, **kwargs):
|
||||
self.cmd("notification", ["info", "This function is disabled on this proxy"])
|
||||
if not config.multiuser_local:
|
||||
self.cmd("notification", ["info", "This function is disabled on this proxy"])
|
||||
else:
|
||||
return super(UiWebsocketPlugin, self).actionServerShutdown(to, *args, **kwargs)
|
||||
|
||||
def actionServerUpdate(self, to, *args, **kwargs):
|
||||
self.cmd("notification", ["info", "This function is disabled on this proxy"])
|
||||
if not config.multiuser_local:
|
||||
self.cmd("notification", ["info", "This function is disabled on this proxy"])
|
||||
else:
|
||||
return super(UiWebsocketPlugin, self).actionServerUpdate(to, *args, **kwargs)
|
||||
|
||||
def actionSiteClone(self, to, *args, **kwargs):
|
||||
self.cmd("notification", ["info", "This function is disabled on this proxy"])
|
||||
if not config.multiuser_local:
|
||||
self.cmd("notification", ["info", "This function is disabled on this proxy"])
|
||||
else:
|
||||
return super(UiWebsocketPlugin, self).actionSiteClone(to, *args, **kwargs)
|
||||
|
||||
|
||||
@PluginManager.registerTo("ConfigPlugin")
|
||||
class ConfigPlugin(object):
|
||||
def createArguments(self):
|
||||
group = self.parser.add_argument_group("Multiuser plugin")
|
||||
group.add_argument('--multiuser_local', help="Enable unsafe Ui functions and write users to disk", action='store_true')
|
||||
|
||||
return super(ConfigPlugin, self).createArguments()
|
||||
|
|
35
plugins/disabled-Multiuser/UserPlugin.py
Normal file
35
plugins/disabled-Multiuser/UserPlugin.py
Normal file
|
@ -0,0 +1,35 @@
|
|||
from Config import config
|
||||
from Plugin import PluginManager
|
||||
|
||||
allow_reload = False
|
||||
|
||||
@PluginManager.registerTo("UserManager")
|
||||
class UserManagerPlugin(object):
|
||||
def load(self):
|
||||
if not config.multiuser_local:
|
||||
# In multiuser mode do not load the users
|
||||
if not self.users:
|
||||
self.users = {}
|
||||
return self.users
|
||||
else:
|
||||
return super(UserManagerPlugin, self).load()
|
||||
|
||||
# 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):
|
||||
if not config.multiuser_local:
|
||||
return False
|
||||
else:
|
||||
return super(UserPlugin, self).save()
|
|
@ -8,7 +8,7 @@ class Config(object):
|
|||
|
||||
def __init__(self, argv):
|
||||
self.version = "0.3.6"
|
||||
self.rev = 986
|
||||
self.rev = 989
|
||||
self.argv = argv
|
||||
self.action = None
|
||||
self.config_file = "zeronet.conf"
|
||||
|
|
Loading…
Reference in a new issue