Skip to content

Commit

Permalink
fix(api): owner ID should be zero when created repo secret (go-gitea#…
Browse files Browse the repository at this point in the history
…31715)

- Change condition to include `RepoID` equal to 0 for organization
secrets

---------

Signed-off-by: Bo-Yi Wu <[email protected]>
Co-authored-by: Giteabot <[email protected]>
  • Loading branch information
appleboy and GiteaBot committed Aug 9, 2024
1 parent 144648a commit 0efd5f2
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions routers/api/v1/repo/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,11 @@ func (Action) CreateOrUpdateSecret(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"

owner := ctx.Repo.Owner
repo := ctx.Repo.Repository

opt := web.GetForm(ctx).(*api.CreateOrUpdateSecretOption)

_, created, err := secret_service.CreateOrUpdateSecret(ctx, owner.ID, repo.ID, ctx.Params("secretname"), opt.Data)
_, created, err := secret_service.CreateOrUpdateSecret(ctx, 0, repo.ID, ctx.Params("secretname"), opt.Data)
if err != nil {
if errors.Is(err, util.ErrInvalidArgument) {
ctx.Error(http.StatusBadRequest, "CreateOrUpdateSecret", err)
Expand Down Expand Up @@ -173,10 +172,9 @@ func (Action) DeleteSecret(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"

owner := ctx.Repo.Owner
repo := ctx.Repo.Repository

err := secret_service.DeleteSecretByName(ctx, owner.ID, repo.ID, ctx.Params("secretname"))
err := secret_service.DeleteSecretByName(ctx, 0, repo.ID, ctx.Params("secretname"))
if err != nil {
if errors.Is(err, util.ErrInvalidArgument) {
ctx.Error(http.StatusBadRequest, "DeleteSecret", err)
Expand Down

0 comments on commit 0efd5f2

Please sign in to comment.