Fix bug 742
[osm/NBI.git] / osm_nbi / admin_topics.py
index 968788a..76d4de8 100644 (file)
@@ -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)