X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FNBI.git;a=blobdiff_plain;f=osm_nbi%2Fadmin_topics.py;h=76d4de816cf824058b887e0a692c85497849cf98;hp=968788aea07fe9148a08d135ddcde0931a255193;hb=refs%2Fchanges%2F26%2F7626%2F1;hpb=c768937d5bb7b31e827aca36c9ab8c3cf1fdb34b diff --git a/osm_nbi/admin_topics.py b/osm_nbi/admin_topics.py index 968788a..76d4de8 100644 --- a/osm_nbi/admin_topics.py +++ b/osm_nbi/admin_topics.py @@ -508,8 +508,9 @@ class UserTopicAuth(UserTopic): self.format_on_new(content, session["project_id"], make_public=session["public"]) _id = self.auth.create_user(content["username"], content["password"])["_id"] - for mapping in content["project_role_mappings"]: - self.auth.assign_role_to_user(_id, mapping["project"], mapping["role"]) + if "project_role_mappings" in content.keys(): + for mapping in content["project_role_mappings"]: + self.auth.assign_role_to_user(_id, mapping["project"], mapping["role"]) rollback.append({"topic": self.topic, "_id": _id}) del content["password"] @@ -768,7 +769,7 @@ class RoleTopicAuth(BaseTopic): raise ValidationError("Operation authorization \".\" should be True/False.") if role_def[-1] == ":": raise ValidationError("Operation cannot end with \".\"") - + role_def_matches = [op for op in operations if op.startswith(role_def)] if len(role_def_matches) == 0: @@ -847,7 +848,7 @@ class RoleTopicAuth(BaseTopic): """ roles = self.auth.get_role_list() system_admin_role = [role for role in roles - if roles["name"] == "system_admin"][0] + if role["name"] == "system_admin"][0] if _id == system_admin_role["_id"]: raise EngineException("You cannot delete system_admin role", http_code=HTTPStatus.FORBIDDEN)