mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2025-01-19 01:35:28 +01:00
Fixing Allowed Server on Config Page
This commit is contained in:
parent
74912a8648
commit
eee528f329
@ -46,7 +46,7 @@ class Users(Model):
|
|||||||
class Meta:
|
class Meta:
|
||||||
table_name = "users"
|
table_name = "users"
|
||||||
database = database
|
database = database
|
||||||
|
|
||||||
#************************************************************************************************
|
#************************************************************************************************
|
||||||
# User Roles Class
|
# User Roles Class
|
||||||
#************************************************************************************************
|
#************************************************************************************************
|
||||||
@ -63,7 +63,7 @@ class User_Roles(Model):
|
|||||||
# Users Helpers
|
# Users Helpers
|
||||||
#************************************************************************************************
|
#************************************************************************************************
|
||||||
class helper_users:
|
class helper_users:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_by_id(user_id):
|
def get_by_id(user_id):
|
||||||
return Users.get_by_id(user_id)
|
return Users.get_by_id(user_id)
|
||||||
@ -97,12 +97,12 @@ class helper_users:
|
|||||||
return user
|
return user
|
||||||
else:
|
else:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def user_query(user_id):
|
def user_query(user_id):
|
||||||
user_query = Users.select().where(Users.user_id == user_id)
|
user_query = Users.select().where(Users.user_id == user_id)
|
||||||
return user_query
|
return user_query
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_user(user_id):
|
def get_user(user_id):
|
||||||
if user_id == 0:
|
if user_id == 0:
|
||||||
@ -168,7 +168,7 @@ class helper_users:
|
|||||||
if not users_helper.get_user(user_id):
|
if not users_helper.get_user(user_id):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def new_api_token():
|
def new_api_token():
|
||||||
while True:
|
while True:
|
||||||
@ -176,7 +176,7 @@ class helper_users:
|
|||||||
test = list(Users.select(Users.user_id).where(Users.api_token == token))
|
test = list(Users.select(Users.user_id).where(Users.api_token == token))
|
||||||
if len(test) == 0:
|
if len(test) == 0:
|
||||||
return token
|
return token
|
||||||
|
|
||||||
#************************************************************************************************
|
#************************************************************************************************
|
||||||
# User_Roles Methods
|
# User_Roles Methods
|
||||||
#************************************************************************************************
|
#************************************************************************************************
|
||||||
@ -216,7 +216,7 @@ class helper_users:
|
|||||||
user_id = user.user_id
|
user_id = user.user_id
|
||||||
|
|
||||||
# I just copied this code from get_user, it had those TODOs & comments made by mac - Lukas
|
# I just copied this code from get_user, it had those TODOs & comments made by mac - Lukas
|
||||||
|
|
||||||
roles_query = User_Roles.select().join(Roles, JOIN.INNER).where(User_Roles.user_id == user_id)
|
roles_query = User_Roles.select().join(Roles, JOIN.INNER).where(User_Roles.user_id == user_id)
|
||||||
# TODO: this query needs to be narrower
|
# TODO: this query needs to be narrower
|
||||||
roles = set()
|
roles = set()
|
||||||
@ -226,13 +226,13 @@ class helper_users:
|
|||||||
user['roles'] = roles
|
user['roles'] = roles
|
||||||
#logger.debug("user: ({}) {}".format(user_id, user))
|
#logger.debug("user: ({}) {}".format(user_id, user))
|
||||||
return user
|
return user
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def user_role_query(user_id):
|
def user_role_query(user_id):
|
||||||
user_query = User_Roles.select().where(User_Roles.user_id == user_id)
|
user_query = User_Roles.select().where(User_Roles.user_id == user_id)
|
||||||
query = Roles.select().where(Roles.role_id == -1)
|
query = Roles.select().where(Roles.role_id == -1)
|
||||||
for u in user_query:
|
for u in user_query:
|
||||||
query = Roles.select().where(Roles.role_id == u.role_id)
|
query = query + Roles.select().where(Roles.role_id == u.role_id)
|
||||||
return query
|
return query
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -303,7 +303,6 @@ class PanelHandler(BaseHandler):
|
|||||||
users_list = []
|
users_list = []
|
||||||
role_users = {}
|
role_users = {}
|
||||||
roles = self.controller.roles.get_all_roles()
|
roles = self.controller.roles.get_all_roles()
|
||||||
role_servers = []
|
|
||||||
user_roles = {}
|
user_roles = {}
|
||||||
for user in self.controller.users.get_all_users():
|
for user in self.controller.users.get_all_users():
|
||||||
user_roles_list = self.controller.users.get_user_roles_names(user.user_id)
|
user_roles_list = self.controller.users.get_user_roles_names(user.user_id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user