1
1
mirror of https://github.com/go-gitea/gitea synced 2025-08-24 18:38:28 +00:00

fix permission check for delete tag (#19985) (#20001)

fix #19970

by the way, fix some error response about protected tags.

Signed-off-by: a1012112796 <1012112796@qq.com>
This commit is contained in:
a1012112796
2022-06-18 05:52:47 +08:00
committed by GitHub
parent ae91913132
commit 4b7f0c6c38
7 changed files with 64 additions and 1 deletions

View File

@@ -344,6 +344,8 @@ func DeleteRelease(ctx *context.APIContext) {
// "$ref": "#/responses/empty"
// "404":
// "$ref": "#/responses/notFound"
// "405":
// "$ref": "#/responses/empty"
id := ctx.ParamsInt64(":id")
rel, err := models.GetReleaseByID(id)
@@ -357,6 +359,10 @@ func DeleteRelease(ctx *context.APIContext) {
return
}
if err := releaseservice.DeleteReleaseByID(id, ctx.User, false); err != nil {
if models.IsErrProtectedTagName(err) {
ctx.Error(http.StatusMethodNotAllowed, "delTag", "user not allowed to delete protected tag")
return
}
ctx.Error(http.StatusInternalServerError, "DeleteReleaseByID", err)
return
}