@@ -4785,7 +4785,7 @@ func initHandlers() {
|
|||||||
r.HandleFunc("/api/v1/users/checkusers", checkAdminLogin).Methods("GET", "OPTIONS")
|
r.HandleFunc("/api/v1/users/checkusers", checkAdminLogin).Methods("GET", "OPTIONS")
|
||||||
r.HandleFunc("/api/v1/users/getinfo", handleInfo).Methods("GET", "OPTIONS")
|
r.HandleFunc("/api/v1/users/getinfo", handleInfo).Methods("GET", "OPTIONS")
|
||||||
|
|
||||||
r.HandleFunc("/api/v1/users/apps", getUserApps).Methods("GET", "OPTIONS")
|
r.HandleFunc("/api/v1/users/apps", shuffle.HandleGetUserApps).Methods("GET", "OPTIONS")
|
||||||
r.HandleFunc("/api/v1/users/generateapikey", shuffle.HandleApiGeneration).Methods("GET", "POST", "OPTIONS")
|
r.HandleFunc("/api/v1/users/generateapikey", shuffle.HandleApiGeneration).Methods("GET", "POST", "OPTIONS")
|
||||||
r.HandleFunc("/api/v1/users/logout", shuffle.HandleLogout).Methods("POST", "OPTIONS")
|
r.HandleFunc("/api/v1/users/logout", shuffle.HandleLogout).Methods("POST", "OPTIONS")
|
||||||
r.HandleFunc("/api/v1/users/getsettings", shuffle.HandleSettings).Methods("GET", "OPTIONS")
|
r.HandleFunc("/api/v1/users/getsettings", shuffle.HandleSettings).Methods("GET", "OPTIONS")
|
||||||
|
|||||||
@@ -2404,70 +2404,6 @@ func setExampleresult(ctx context.Context, result shuffle.AppExecutionExample) e
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getUserApps(resp http.ResponseWriter, request *http.Request) {
|
|
||||||
cors := shuffle.HandleCors(resp, request)
|
|
||||||
if cors {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx := context.Background()
|
|
||||||
user, userErr := shuffle.HandleApiAuthentication(resp, request)
|
|
||||||
if userErr != nil {
|
|
||||||
log.Printf("[WARNING] Api authentication failed in get all apps - this does NOT require auth in the cloud.: %s", userErr)
|
|
||||||
resp.WriteHeader(401)
|
|
||||||
resp.Write([]byte(`{"success": false}`))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
workflowapps, err := shuffle.GetAllWorkflowApps(ctx, 1000, 0)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("[WARNING] Failed getting apps (getworkflowapps): %s", err)
|
|
||||||
resp.WriteHeader(401)
|
|
||||||
resp.Write([]byte(`{"success": false}`))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
filteredApps := workflowapps[:0]
|
|
||||||
for _, app := range workflowapps {
|
|
||||||
if app.Owner == user.Id {
|
|
||||||
filteredApps = append(filteredApps, app)
|
|
||||||
} else if app.Contributors != nil {
|
|
||||||
for _, contributor := range app.Contributors {
|
|
||||||
if contributor == user.Id {
|
|
||||||
filteredApps = append(filteredApps, app)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(user.PrivateApps) > 0 {
|
|
||||||
for _, item := range user.PrivateApps {
|
|
||||||
found := false
|
|
||||||
for _, app := range filteredApps {
|
|
||||||
if item.ID == app.ID || !(item.Owner == user.Id) {
|
|
||||||
found = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if !found {
|
|
||||||
filteredApps = append(filteredApps, item)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
newbody, err := json.Marshal(filteredApps)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("[ERROR] Failed unmarshalling all newapps: %s", err)
|
|
||||||
resp.WriteHeader(401)
|
|
||||||
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Failed unpacking workflow apps"}`)))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
resp.WriteHeader(200)
|
|
||||||
resp.Write(newbody)
|
|
||||||
}
|
|
||||||
|
|
||||||
func getWorkflowApps(resp http.ResponseWriter, request *http.Request) {
|
func getWorkflowApps(resp http.ResponseWriter, request *http.Request) {
|
||||||
cors := shuffle.HandleCors(resp, request)
|
cors := shuffle.HandleCors(resp, request)
|
||||||
if cors {
|
if cors {
|
||||||
|
|||||||
Reference in New Issue
Block a user