if session["admin"]: # allows all
return {}
else:
- return {"username": session["username"]}
+ return {"_id": session["user_id"]}
def check_conflict_on_new(self, session, indata):
# check username not exists
:param db_content: The database content of this item _id
:return: None if ok or raises EngineException with the conflict
"""
- if db_content["username"] == session["username"]:
+ if db_content["_id"] == session["user_id"]:
raise EngineException(
"You cannot delete your own login user ", http_code=HTTPStatus.CONFLICT
)
user_list = self.auth.get_user_list(filter_q)
if not session["allow_show_user_project_role"]:
# Bug 853 - Default filtering
- user_list = [
- usr for usr in user_list if usr["username"] == session["username"]
- ]
+ user_list = [usr for usr in user_list if usr["_id"] == session["user_id"]]
return user_list
def delete(self, session, _id, dry_run=False, not_send_msg=None):
project_list = self.auth.get_project_list(filter_q)
if not session["allow_show_user_project_role"]:
# Bug 853 - Default filtering
- user = self.auth.get_user(session["username"])
+ user = self.auth.get_user(session["user_id"])
projects = [prm["project"] for prm in user["project_role_mappings"]]
project_list = [proj for proj in project_list if proj["_id"] in projects]
return project_list
role_list = self.auth.get_role_list(filter_q)
if not session["allow_show_user_project_role"]:
# Bug 853 - Default filtering
- user = self.auth.get_user(session["username"])
+ user = self.auth.get_user(session["user_id"])
roles = [prm["role"] for prm in user["project_role_mappings"]]
role_list = [role for role in role_list if role["_id"] in roles]
return role_list
def test_delete_user(self):
with self.subTest(i=1):
uid = str(uuid4())
- self.fake_session["username"] = self.test_name
+ other_uid = str(uuid4())
+ self.fake_session["user_id"] = other_uid
user = user = {
"_id": uid,
"username": "other-user-name",
def test_conflict_on_del(self):
with self.subTest(i=1):
uid = str(uuid4())
- self.fake_session["username"] = self.test_name
+ self.fake_session["user_id"] = uid
user = user = {
"_id": uid,
"username": self.test_name,