Skip to content

Commit

Permalink
PMM-13633 Nil response instead error in case of it is not SA.
Browse files Browse the repository at this point in the history
  • Loading branch information
JiriCtvrtka committed Dec 27, 2024
1 parent a7138e1 commit 854b7df
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/services/serviceaccounts/api/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (api *ServiceAccountsAPI) ListTokens(ctx *contextmodel.ReqContext) response
// @PERCONA
// swagger:route GET /auth/serviceaccount serviceaccounts retrieveServiceAccount
//
// # CurrentServiceAccount get current service account info
// # CurrentServiceAccount get current service account info, in case of nil it is not service account.
//
// Requires service account token authentication.
//
Expand All @@ -126,7 +126,7 @@ func (api *ServiceAccountsAPI) ListTokens(ctx *contextmodel.ReqContext) response
// 500: internalServerError
func (api *ServiceAccountsAPI) CurrentServiceAccount(ctx *contextmodel.ReqContext) response.Response {
if !ctx.IsServiceAccount {
return response.Error(http.StatusBadRequest, "Auth method is not service account token", errors.New("failed to get service account info"))
return response.JSON(http.StatusOK, nil)
}

serviceAccount, err := api.service.RetrieveServiceAccount(ctx.Req.Context(), ctx.OrgID, ctx.UserID)
Expand Down

0 comments on commit 854b7df

Please sign in to comment.