version 0.2.0, new lib for bitcoin ecc, dont display or track notify errors, dont reload again within 1 sec, null peer ip fix, signingmoved to ContentManager, content.json include support, content.json multisig ready, content.json proper bitcoincore compatible signing, content.json include permissions, multithreaded publish, publish timeout 60s, no exception on invalid bitcoin address, testcase for new lib, bip32 based persite privatekey generation, multiuser ready, simple json database query command, websocket api fileGet, wrapper loading title stuck bugfix
2015-02-09 02:09:02 +01:00
|
|
|
import json, logging, os
|
|
|
|
from User import User
|
version 0.2.7, plugin system, multiuser plugin for zeroproxies, reworked imports, cookie parse, stats moved to plugin, usermanager class, dont generate site auth on listing, multiline notifications, allow server side prompt from user, update script keep plugins disabled status
2015-03-24 01:33:09 +01:00
|
|
|
from Plugin import PluginManager
|
2015-05-31 15:52:21 +02:00
|
|
|
from Config import config
|
version 0.2.0, new lib for bitcoin ecc, dont display or track notify errors, dont reload again within 1 sec, null peer ip fix, signingmoved to ContentManager, content.json include support, content.json multisig ready, content.json proper bitcoincore compatible signing, content.json include permissions, multithreaded publish, publish timeout 60s, no exception on invalid bitcoin address, testcase for new lib, bip32 based persite privatekey generation, multiuser ready, simple json database query command, websocket api fileGet, wrapper loading title stuck bugfix
2015-02-09 02:09:02 +01:00
|
|
|
|
|
|
|
|
version 0.2.7, plugin system, multiuser plugin for zeroproxies, reworked imports, cookie parse, stats moved to plugin, usermanager class, dont generate site auth on listing, multiline notifications, allow server side prompt from user, update script keep plugins disabled status
2015-03-24 01:33:09 +01:00
|
|
|
@PluginManager.acceptPlugins
|
|
|
|
class UserManager(object):
|
|
|
|
def __init__(self):
|
|
|
|
self.users = {}
|
|
|
|
|
|
|
|
|
|
|
|
# Load all user from data/users.json
|
|
|
|
def load(self):
|
|
|
|
if not self.users: self.users = {}
|
|
|
|
|
|
|
|
user_found = []
|
|
|
|
added = 0
|
|
|
|
# Load new users
|
2015-05-31 15:52:21 +02:00
|
|
|
for master_address, data in json.load(open("%s/users.json" % config.data_dir)).items():
|
version 0.2.7, plugin system, multiuser plugin for zeroproxies, reworked imports, cookie parse, stats moved to plugin, usermanager class, dont generate site auth on listing, multiline notifications, allow server side prompt from user, update script keep plugins disabled status
2015-03-24 01:33:09 +01:00
|
|
|
if master_address not in self.users:
|
version 0.3.0, rev187, Trusted authorization sites support, --publish option on signing, cryptSign command line option, OpenSSL enabled on OSX, Crypto verify allows list of valid addresses, Option for version 2 json DB tables, DbCursor SELECT parameters bugfix, Add peer to site on ListModified, Download blind includes when new site added, Publish command better messages, Multi-threaded announce, New http Torrent trackers, Wait for dbschema.json on query, Handle json import errors, More compact writeJson storage command, Testcase for signing and verifying, Workaround to make non target=_top links work, More clean UiWebsocket command route, Send cert_user_id on siteinfo, Notify other local clients on local file modify, Option to wait for file download before sql query, File rules websocket API command, Cert add and select, set websocket API command, Put focus on innerframe, innerloaded wrapper api command to add hashtag, Allow more file error on big sites, Keep worker running after stuked on done task, New more stable openSSL layer that works on OSX, Noparallel parameter bugfix, RateLimit allowed again interval bugfix, Updater skips non-writeable files, Try to close openssl dll before update
2015-05-25 01:26:33 +02:00
|
|
|
user = User(master_address, data=data)
|
version 0.2.7, plugin system, multiuser plugin for zeroproxies, reworked imports, cookie parse, stats moved to plugin, usermanager class, dont generate site auth on listing, multiline notifications, allow server side prompt from user, update script keep plugins disabled status
2015-03-24 01:33:09 +01:00
|
|
|
self.users[master_address] = user
|
|
|
|
added += 1
|
|
|
|
user_found.append(master_address)
|
|
|
|
|
|
|
|
# Remove deleted adresses
|
|
|
|
for master_address in self.users.keys():
|
|
|
|
if master_address not in user_found:
|
|
|
|
del(self.users[master_address])
|
|
|
|
logging.debug("Removed user: %s" % master_address)
|
|
|
|
|
|
|
|
if added: logging.debug("UserManager added %s users" % added)
|
|
|
|
|
|
|
|
|
|
|
|
# Create new user
|
|
|
|
# Return: User
|
|
|
|
def create(self, master_address=None, master_seed=None):
|
|
|
|
user = User(master_address, master_seed)
|
|
|
|
logging.debug("Created user: %s" % user.master_address)
|
|
|
|
if user.master_address: # If successfully created
|
|
|
|
self.users[user.master_address] = user
|
|
|
|
user.save()
|
|
|
|
return user
|
|
|
|
|
|
|
|
|
|
|
|
# List all users from data/users.json
|
|
|
|
# Return: {"usermasteraddr": User}
|
|
|
|
def list(self):
|
|
|
|
if self.users == {}: # Not loaded yet
|
|
|
|
self.load()
|
|
|
|
return self.users
|
|
|
|
|
|
|
|
|
|
|
|
# Get user based on master_address
|
|
|
|
# Return: User or None
|
|
|
|
def get(self, master_address=None):
|
|
|
|
users = self.list()
|
|
|
|
if users:
|
|
|
|
return users.values()[0] # Single user mode, always return the first
|
|
|
|
else:
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
user_manager = UserManager() # Singletone
|
version 0.2.0, new lib for bitcoin ecc, dont display or track notify errors, dont reload again within 1 sec, null peer ip fix, signingmoved to ContentManager, content.json include support, content.json multisig ready, content.json proper bitcoincore compatible signing, content.json include permissions, multithreaded publish, publish timeout 60s, no exception on invalid bitcoin address, testcase for new lib, bip32 based persite privatekey generation, multiuser ready, simple json database query command, websocket api fileGet, wrapper loading title stuck bugfix
2015-02-09 02:09:02 +01:00
|
|
|
|
|
|
|
# Debug: Reload User.py
|
version 0.2.7, plugin system, multiuser plugin for zeroproxies, reworked imports, cookie parse, stats moved to plugin, usermanager class, dont generate site auth on listing, multiline notifications, allow server side prompt from user, update script keep plugins disabled status
2015-03-24 01:33:09 +01:00
|
|
|
def reloadModule():
|
|
|
|
return "Not used"
|
|
|
|
|
|
|
|
import imp
|
|
|
|
global User, UserManager, user_manager
|
version 0.2.0, new lib for bitcoin ecc, dont display or track notify errors, dont reload again within 1 sec, null peer ip fix, signingmoved to ContentManager, content.json include support, content.json multisig ready, content.json proper bitcoincore compatible signing, content.json include permissions, multithreaded publish, publish timeout 60s, no exception on invalid bitcoin address, testcase for new lib, bip32 based persite privatekey generation, multiuser ready, simple json database query command, websocket api fileGet, wrapper loading title stuck bugfix
2015-02-09 02:09:02 +01:00
|
|
|
User = imp.load_source("User", "src/User/User.py").User # Reload source
|
version 0.2.7, plugin system, multiuser plugin for zeroproxies, reworked imports, cookie parse, stats moved to plugin, usermanager class, dont generate site auth on listing, multiline notifications, allow server side prompt from user, update script keep plugins disabled status
2015-03-24 01:33:09 +01:00
|
|
|
#module = imp.load_source("UserManager", "src/User/UserManager.py") # Reload module
|
|
|
|
#UserManager = module.UserManager
|
|
|
|
#user_manager = module.user_manager
|
|
|
|
# Reload users
|
|
|
|
user_manager = UserManager()
|
|
|
|
user_manager.load()
|