From 5189d23ab0f88075a3b31331fcf6c7ccbc8de2e0 Mon Sep 17 00:00:00 2001 From: tcnichol Date: Thu, 25 Feb 2021 15:40:48 -0600 Subject: [PATCH 1/3] when space is created, add the creator to space as admin --- app/api/Spaces.scala | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/app/api/Spaces.scala b/app/api/Spaces.scala index 3db81f577..f51b49df8 100644 --- a/app/api/Spaces.scala +++ b/app/api/Spaces.scala @@ -1,23 +1,18 @@ package api -import java.util.Date -import javax.inject.Inject import api.Permission.Permission +import controllers.Utils import models._ import play.api.Logger -import controllers.Utils import play.api.Play._ -import play.api.libs.json.Json -import play.api.libs.json.Json._ -import play.api.libs.json.Json.toJson +import play.api.i18n.Messages +import play.api.libs.json.{JsError, JsResult, JsSuccess, Json} +import play.api.libs.json.Json.{toJson, _} import services._ import util.Mail -import play.api.libs.json.JsResult -import play.api.libs.json.JsSuccess -import play.api.libs.json.JsError -import play.api.i18n.Messages -import scala.util.Try +import java.util.Date +import javax.inject.Inject /** * Spaces allow users to partition the data into realms only accessible to users with the right permissions. @@ -51,6 +46,13 @@ class Spaces @Inject()(spaces: SpaceService, case Some(id) => { appConfig.incrementCount('spaces, 1) events.addObjectEvent(request.user, c.id, c.name, "create_space") + userService.findRoleByName("Admin") match { + case Some(realRole) => { + spaces.addUser(userId, realRole, UUID(id)) + } + case None => Logger.info("No admin role found") + + } Ok(toJson(Map("id" -> id))) } case None => Ok(toJson(Map("status" -> "error"))) From 18669c392cef221021987f747b837932f3bc48e6 Mon Sep 17 00:00:00 2001 From: tcnichol Date: Thu, 25 Feb 2021 15:45:04 -0600 Subject: [PATCH 2/3] changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e4190b59..a92d0a985 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## unreleased 2021-02-25 + +- Bugfix. When space created through api the creator was not added to space as admin. Fixed. + ## 1.14.1 - 2021-02-02 - Google will no longer work as login provider, we are working on this issue [#157](https://github.com/clowder-framework/clowder/issues/157). From 167008c0e8a2db5bae40becda1d037201e7c12ca Mon Sep 17 00:00:00 2001 From: tcnichol Date: Thu, 25 Feb 2021 17:04:30 -0600 Subject: [PATCH 3/3] adding issue and issue # to CHANGELOG.md --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a92d0a985..fb8692a66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,9 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## unreleased 2021-02-25 +## Fixed 2021-02-25 -- Bugfix. When space created through api the creator was not added to space as admin. Fixed. +- When space created through api the creator was not added to space as admin [#179](https://github.com/clowder-framework/clowder/issues/179). ## 1.14.1 - 2021-02-02