diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-11-28 19:58:28 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-28 12:58:28 +0100 |
commit | 1fee11d69a437ec7e68b3f6b645827592fe77292 (patch) | |
tree | 1fca452f96746d9f7cc8c31723e3c365155cf96d /routers/web/repo/http.go | |
parent | 24a8d54bfb908a2371cb808a5243b3290dd0664a (diff) | |
download | gitea-1fee11d69a437ec7e68b3f6b645827592fe77292.tar.gz gitea-1fee11d69a437ec7e68b3f6b645827592fe77292.zip |
Move accessmode into models/perm (#17828)
Diffstat (limited to 'routers/web/repo/http.go')
-rw-r--r-- | routers/web/repo/http.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/routers/web/repo/http.go b/routers/web/repo/http.go index ce2d977518..d1978aefe2 100644 --- a/routers/web/repo/http.go +++ b/routers/web/repo/http.go @@ -22,6 +22,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/login" + "code.gitea.io/gitea/models/perm" "code.gitea.io/gitea/models/unit" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/context" @@ -93,11 +94,11 @@ func httpBase(ctx *context.Context) (h *serviceHandler) { isPull = ctx.Req.Method == "GET" } - var accessMode models.AccessMode + var accessMode perm.AccessMode if isPull { - accessMode = models.AccessModeRead + accessMode = perm.AccessModeRead } else { - accessMode = models.AccessModeWrite + accessMode = perm.AccessModeWrite } isWiki := false @@ -194,7 +195,7 @@ func httpBase(ctx *context.Context) (h *serviceHandler) { } if repoExist { - perm, err := models.GetUserRepoPermission(repo, ctx.User) + p, err := models.GetUserRepoPermission(repo, ctx.User) if err != nil { ctx.ServerError("GetUserRepoPermission", err) return @@ -202,10 +203,10 @@ func httpBase(ctx *context.Context) (h *serviceHandler) { // Because of special ref "refs/for" .. , need delay write permission check if git.SupportProcReceive { - accessMode = models.AccessModeRead + accessMode = perm.AccessModeRead } - if !perm.CanAccess(accessMode, unitType) { + if !p.CanAccess(accessMode, unitType) { ctx.HandleText(http.StatusForbidden, "User permission denied") return } |