You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

context_model.go 720B

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