mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Implimenting default.json search for user/pass creation
This commit is contained in:
parent
203441045f
commit
de98e5727c
@ -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')
|
||||
|
@ -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()
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user