Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-26 19:56:11 +01:00

Only delete secrets belonging to its owner (#24284) (#24286)

Backport #24284 by @KN4CK3R

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
This commit is contained in:
Giteabot 2023-04-23 10:36:20 -04:00 committed by GitHub
parent 077160b838
commit 7297cceda7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 2 deletions

View file

@ -43,6 +43,8 @@ func SecretsPost(ctx *context.Context) {
func SecretsDelete(ctx *context.Context) { func SecretsDelete(ctx *context.Context) {
shared.PerformSecretsDelete( shared.PerformSecretsDelete(
ctx, ctx,
ctx.ContextUser.ID,
0,
ctx.Org.OrgLink+"/settings/secrets", ctx.Org.OrgLink+"/settings/secrets",
) )
} }

View file

@ -41,6 +41,8 @@ func SecretsPost(ctx *context.Context) {
func DeleteSecret(ctx *context.Context) { func DeleteSecret(ctx *context.Context) {
shared.PerformSecretsDelete( shared.PerformSecretsDelete(
ctx, ctx,
0,
ctx.Repo.Repository.ID,
ctx.Repo.RepoLink+"/settings/secrets", ctx.Repo.RepoLink+"/settings/secrets",
) )
} }

View file

@ -38,10 +38,10 @@ func PerformSecretsPost(ctx *context.Context, ownerID, repoID int64, redirectURL
ctx.Redirect(redirectURL) ctx.Redirect(redirectURL)
} }
func PerformSecretsDelete(ctx *context.Context, redirectURL string) { func PerformSecretsDelete(ctx *context.Context, ownerID, repoID int64, redirectURL string) {
id := ctx.FormInt64("id") id := ctx.FormInt64("id")
if _, err := db.DeleteByBean(ctx, &secret_model.Secret{ID: id}); err != nil { if _, err := db.DeleteByBean(ctx, &secret_model.Secret{ID: id, OwnerID: ownerID, RepoID: repoID}); err != nil {
log.Error("Delete secret %d failed: %v", id, err) log.Error("Delete secret %d failed: %v", id, err)
ctx.Flash.Error(ctx.Tr("secrets.deletion.failed")) ctx.Flash.Error(ctx.Tr("secrets.deletion.failed"))
} else { } else {

View file

@ -40,6 +40,8 @@ func SecretsPost(ctx *context.Context) {
func SecretsDelete(ctx *context.Context) { func SecretsDelete(ctx *context.Context) {
shared.PerformSecretsDelete( shared.PerformSecretsDelete(
ctx, ctx,
ctx.Doer.ID,
0,
setting.AppSubURL+"/user/settings/secrets", setting.AppSubURL+"/user/settings/secrets",
) )
} }