Implimenting default.json search for user/pass creation

This commit is contained in:
Phillip Tarrant 2020-08-18 21:50:24 -04:00
parent 203441045f
commit de98e5727c
3 changed files with 23 additions and 4 deletions

View File

@ -27,6 +27,7 @@ class Controller:
self.servers_list = []
servers = db_helper.get_all_defined_servers()
print(servers)
for s in servers:
settings_file = os.path.join(s['path'], 'server.properties')

View File

@ -343,4 +343,18 @@ class Helpers:
else:
return False
def find_default_password(self):
default_file = os.path.join(self.root_dir, "default.json")
data = {}
if self.check_file_exists(default_file):
with open(default_file, 'r') as f:
data = json.load(f)
os.remove(default_file)
return data
helper = Helpers()

View File

@ -114,9 +114,15 @@ class db_builder:
@staticmethod
def default_settings():
default_data = helper.find_default_password()
username = default_data.get("username", 'Admin')
password = default_data.get("password", 'crafty')
Users.insert({
Users.username: 'Admin',
Users.password: helper.encode_pass('asdfasdf'),
Users.username: username,
Users.password: helper.encode_pass(password),
Users.api_token: helper.random_string_generator(32),
Users.enabled: True
}).execute()
@ -136,8 +142,6 @@ class db_shortcuts:
if query:
for s in query:
rows.append(model_to_dict(s))
else:
rows.append({})
return rows
def get_all_defined_servers(self):