Skip to content

Commit 423fb27

Browse files
authored
fix(api): get integration with clear password from services (#5149)
1 parent 581a47c commit 423fb27

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

engine/api/project_integration.go

+23-7
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,32 @@ func (api *API) getProjectIntegrationHandler() service.Handler {
2020
projectKey := vars[permProjectKey]
2121
integrationName := vars["integrationName"]
2222

23-
integration, err := integration.LoadProjectIntegrationByName(api.mustDB(), projectKey, integrationName)
24-
if err != nil {
25-
return sdk.WrapError(err, "Cannot load integration %s/%s", projectKey, integrationName)
23+
var integ sdk.ProjectIntegration
24+
var err error
25+
26+
clearPassword := FormBool(r, "clearPassword")
27+
if clearPassword {
28+
if !isService(ctx) {
29+
return sdk.ErrForbidden
30+
}
31+
integ, err = integration.LoadProjectIntegrationByNameWithClearPassword(api.mustDB(), projectKey, integrationName)
32+
if err != nil {
33+
return sdk.WrapError(err, "Cannot load integration %s/%s", projectKey, integrationName)
34+
}
35+
} else {
36+
integ, err = integration.LoadProjectIntegrationByName(api.mustDB(), projectKey, integrationName)
37+
if err != nil {
38+
return sdk.WrapError(err, "Cannot load integration %s/%s", projectKey, integrationName)
39+
}
2640
}
27-
plugins, err := plugin.LoadAllByIntegrationModelID(api.mustDB(), integration.IntegrationModelID)
41+
42+
plugins, err := plugin.LoadAllByIntegrationModelID(api.mustDB(), integ.IntegrationModelID)
2843
if err != nil {
29-
return sdk.WrapError(err, "Cannot load integration %s/%s", projectKey, integrationName)
44+
return sdk.WrapError(err, "Cannot load integration plugin %s/%s", projectKey, integrationName)
3045
}
31-
integration.GRPCPlugins = plugins
32-
return service.WriteJSON(w, integration, http.StatusOK)
46+
integ.GRPCPlugins = plugins
47+
48+
return service.WriteJSON(w, integ, http.StatusOK)
3349
}
3450
}
3551

0 commit comments

Comments
 (0)