feat(api tokens): add task attachment to api scopes
This explicitly adds download and upload of task attachments. Because these are not handled with the usual CRUDables, they were not picked up automatically. Resolves https://github.com/go-vikunja/vikunja/issues/112
This commit is contained in:
parent
ebe25ee2d7
commit
415c6380a5
@ -69,7 +69,7 @@ func getRouteGroupName(path string) string {
|
||||
// CollectRoutesForAPITokenUsage gets called for every added APITokenRoute and builds a list of all routes we can use for the api tokens.
|
||||
func CollectRoutesForAPITokenUsage(route echo.Route) {
|
||||
|
||||
if !strings.Contains(route.Name, "(*WebHandler)") {
|
||||
if !strings.Contains(route.Name, "(*WebHandler)") && !strings.Contains(route.Name, "Attachment") {
|
||||
return
|
||||
}
|
||||
|
||||
@ -116,6 +116,21 @@ func CollectRoutesForAPITokenUsage(route echo.Route) {
|
||||
Method: route.Method,
|
||||
}
|
||||
}
|
||||
|
||||
if routeGroupName == "tasks_attachments" {
|
||||
if strings.Contains(route.Name, "UploadTaskAttachment") {
|
||||
apiTokenRoutes[routeGroupName].Create = &RouteDetail{
|
||||
Path: route.Path,
|
||||
Method: route.Method,
|
||||
}
|
||||
}
|
||||
if strings.Contains(route.Name, "GetTaskAttachment") {
|
||||
apiTokenRoutes[routeGroupName].ReadOne = &RouteDetail{
|
||||
Path: route.Path,
|
||||
Method: route.Method,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// GetAvailableAPIRoutesForToken returns a list of all API routes which are available for token usage.
|
||||
|
Loading…
x
Reference in New Issue
Block a user