From: Eduardo Sousa Date: Tue, 4 Jun 2019 08:20:01 +0000 (+0100) Subject: Fix bug 730 X-Git-Tag: v6.0.0~16 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F02%2F7602%2F6;p=osm%2FNBI.git Fix bug 730 Change-Id: Ifa24d848793f36861e7a8c4c2185e0c6ae7d7b09 Signed-off-by: Eduardo Sousa --- diff --git a/osm_nbi/admin_topics.py b/osm_nbi/admin_topics.py index b0dc087..2bc3003 100644 --- a/osm_nbi/admin_topics.py +++ b/osm_nbi/admin_topics.py @@ -412,15 +412,15 @@ class UserTopicAuth(UserTopic): :return: None or raises EngineException """ users = self.auth.get_user_list() - admin_user = [user for user in users if user["name"] == "admin"][0] + admin_user = [user for user in users if user["username"] == "admin"][0] - if _id == admin_user["_id"] and edit_content["project_role_mappings"]: + if _id == admin_user["_id"] and "project_role_mappings" in edit_content.keys(): elem = { "project": "admin", "role": "system_admin" } if elem not in edit_content: - raise EngineException("You cannot remove system_admin role from admin user", + raise EngineException("You cannot remove system_admin role from admin user", http_code=HTTPStatus.FORBIDDEN) def check_conflict_on_del(self, session, _id, db_content): @@ -560,7 +560,7 @@ class UserTopicAuth(UserTopic): self.format_on_edit(content, indata) if "password" in content: - self.auth.change_password(content["name"], content["password"]) + self.auth.change_password(content["username"], content["password"]) else: user = self.show(session, _id) original_mapping = user["project_role_mappings"] @@ -574,14 +574,14 @@ class UserTopicAuth(UserTopic): for mapping in mappings_to_remove: self.auth.remove_role_from_user( - user["name"], + _id, mapping["project"], mapping["role"] ) for mapping in mappings_to_add: self.auth.assign_role_to_user( - user["name"], + _id, mapping["project"], mapping["role"] )