Skip to content

Commit 4ced603

Browse files
author
Leandro Ferreira
committed
Adding auth for folder by id
1 parent 6d3b6de commit 4ced603

1 file changed

Lines changed: 20 additions & 18 deletions

File tree

  • backend/documents/documents/src/main/java/io/writeopia/api/documents/routing

backend/documents/documents/src/main/java/io/writeopia/api/documents/routing/DocumentsRouting.kt

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -131,24 +131,26 @@ fun Routing.documentsRoute(
131131
}
132132
}
133133

134-
get("/api/workspace/{workspaceId}/folder/{id}") {
135-
val id = call.pathParameters["id"]!!
136-
val userId = getUserId() ?: ""
137-
val workspaceId = call.pathParameters["workspaceId"] ?: ""
138-
139-
runIfMember(userId, workspaceId, writeopiaDb, debug) {
140-
val folder = DocumentsService.getFolderById(id, userId, writeopiaDb)
141-
142-
if (folder != null) {
143-
call.respond(
144-
status = HttpStatusCode.OK,
145-
message = folder.toApi()
146-
)
147-
} else {
148-
call.respond(
149-
status = HttpStatusCode.NotFound,
150-
message = "No lead with id: $id"
151-
)
134+
authenticate("auth-jwt", optional = debug) {
135+
get("/api/workspace/{workspaceId}/folder/{id}") {
136+
val id = call.pathParameters["id"]!!
137+
val userId = getUserId() ?: ""
138+
val workspaceId = call.pathParameters["workspaceId"] ?: ""
139+
140+
runIfMember(userId, workspaceId, writeopiaDb, debug) {
141+
val folder = DocumentsService.getFolderById(id, userId, writeopiaDb)
142+
143+
if (folder != null) {
144+
call.respond(
145+
status = HttpStatusCode.OK,
146+
message = folder.toApi()
147+
)
148+
} else {
149+
call.respond(
150+
status = HttpStatusCode.NotFound,
151+
message = "No lead with id: $id"
152+
)
153+
}
152154
}
153155
}
154156
}

0 commit comments

Comments
 (0)