code.gitea.io/gitea@v1.22.3/services/context/context_model.go (about) 1 // Copyright 2023 The Gitea Authors. All rights reserved. 2 // SPDX-License-Identifier: MIT 3 4 package context 5 6 import ( 7 "code.gitea.io/gitea/models/unit" 8 ) 9 10 // IsUserSiteAdmin returns true if current user is a site admin 11 func (ctx *Context) IsUserSiteAdmin() bool { 12 return ctx.IsSigned && ctx.Doer.IsAdmin 13 } 14 15 // IsUserRepoAdmin returns true if current user is admin in current repo 16 func (ctx *Context) IsUserRepoAdmin() bool { 17 return ctx.Repo.IsAdmin() 18 } 19 20 // IsUserRepoWriter returns true if current user has write privilege in current repo 21 func (ctx *Context) IsUserRepoWriter(unitTypes []unit.Type) bool { 22 for _, unitType := range unitTypes { 23 if ctx.Repo.CanWrite(unitType) { 24 return true 25 } 26 } 27 28 return false 29 }