1
1
mirror of https://github.com/go-gitea/gitea synced 2025-01-10 09:44:43 +00:00

refactor: remove unnessary condition in reqSelfOrAdmin middleware

This commit is contained in:
eyad-hussein 2024-07-31 14:21:22 +03:00
parent d41dc95f10
commit f3f69085d9

View File

@ -479,12 +479,11 @@ func reqOwner() func(ctx *context.APIContext) {
// reqSelfOrAdmin doer should be the same as the contextUser or site admin // reqSelfOrAdmin doer should be the same as the contextUser or site admin
func reqSelfOrAdmin() func(ctx *context.APIContext) { func reqSelfOrAdmin() func(ctx *context.APIContext) {
return func(ctx *context.APIContext) { return func(ctx *context.APIContext) {
if ctx.ContextUser.IsIndividual() {
if !ctx.IsUserSiteAdmin() && ctx.ContextUser != ctx.Doer { if !ctx.IsUserSiteAdmin() && ctx.ContextUser != ctx.Doer {
ctx.Error(http.StatusForbidden, "reqSelfOrAdmin", "doer should be the site admin or be same as the contextUser") ctx.Error(http.StatusForbidden, "reqSelfOrAdmin", "doer should be the site admin or be same as the contextUser")
return return
} }
}
} }
} }