From de662207a4ba1fdcb7c50b73d950e61fc59a23ac Mon Sep 17 00:00:00 2001 From: harryzcy Date: Sat, 5 Nov 2022 21:12:26 -0400 Subject: [PATCH] Remove unused function --- routers/api/v1/api.go | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 12db1940f6..38ff8e4ec2 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -251,7 +251,8 @@ func reqToken(requiredScope string) func(ctx *context.APIContext) { } } -func reqTokenOrSiteAdmin(requiredScope string) func(ctx *context.APIContext) { +// reqSiteAdminOrToken user should be the site admin, or the token should have 'sudo' scope. +func reqSiteAdminOrToken() func(ctx *context.APIContext) { return func(ctx *context.APIContext) { // if is site admin, allow it if ctx.IsUserSiteAdmin() { @@ -259,7 +260,7 @@ func reqTokenOrSiteAdmin(requiredScope string) func(ctx *context.APIContext) { } // otherwise, check token - reqToken(requiredScope)(ctx) + reqToken("sudo")(ctx) } } @@ -284,16 +285,6 @@ func reqBasicOrRevProxyAuth() func(ctx *context.APIContext) { } } -// reqSiteAdmin user should be the site admin -func reqSiteAdmin() func(ctx *context.APIContext) { - return func(ctx *context.APIContext) { - if !ctx.IsUserSiteAdmin() { - ctx.Error(http.StatusForbidden, "reqSiteAdmin", "user should be the site admin") - return - } - } -} - // reqOwner user should be the owner of the repo or site admin. func reqOwner() func(ctx *context.APIContext) { return func(ctx *context.APIContext) { @@ -1218,7 +1209,7 @@ func Routes(ctx gocontext.Context) *web.Route { m.Post("/{username}/{reponame}", admin.AdoptRepository) m.Delete("/{username}/{reponame}", admin.DeleteUnadoptedRepository) }) - }, reqTokenOrSiteAdmin(auth_model.AccessTokenScopeSudo)) + }, reqSiteAdminOrToken()) m.Group("/topics", func() { m.Get("/search", repo.TopicSearch)