Skip to content

Commit b512cb4

Browse files
tcnichollmarini
andauthored
when space is created, add the creator to space as admin (#180)
* when space is created, add the creator to space as admin * changelog * adding issue and issue # to CHANGELOG.md Co-authored-by: Luigi Marini <[email protected]>
1 parent fc65eb1 commit b512cb4

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1111

1212
### Fixed
1313
- Clowder will no longer offer a Download button for a file until it has been PROCESSED.
14+
- When space created through api the creator was not added to space as admin [#179](https://github.com/clowder-framework/clowder/issues/179).
1415

1516
### Changed
1617
- `/api/me` will now return some of the same information as response headers.

app/api/Spaces.scala

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
package api
22

3-
import java.util.Date
4-
import javax.inject.Inject
53
import api.Permission.Permission
4+
import controllers.Utils
65
import models._
76
import play.api.Logger
8-
import controllers.Utils
97
import play.api.Play._
10-
import play.api.libs.json.Json
11-
import play.api.libs.json.Json._
12-
import play.api.libs.json.Json.toJson
8+
import play.api.i18n.Messages
9+
import play.api.libs.json.{JsError, JsResult, JsSuccess, Json}
10+
import play.api.libs.json.Json.{toJson, _}
1311
import services._
1412
import util.Mail
15-
import play.api.libs.json.JsResult
16-
import play.api.libs.json.JsSuccess
17-
import play.api.libs.json.JsError
18-
import play.api.i18n.Messages
1913

20-
import scala.util.Try
14+
import java.util.Date
15+
import javax.inject.Inject
2116

2217
/**
2318
* 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,
5146
case Some(id) => {
5247
appConfig.incrementCount('spaces, 1)
5348
events.addObjectEvent(request.user, c.id, c.name, "create_space")
49+
userService.findRoleByName("Admin") match {
50+
case Some(realRole) => {
51+
spaces.addUser(userId, realRole, UUID(id))
52+
}
53+
case None => Logger.info("No admin role found")
54+
55+
}
5456
Ok(toJson(Map("id" -> id)))
5557
}
5658
case None => Ok(toJson(Map("status" -> "error")))

0 commit comments

Comments
 (0)