diff options
author | a1012112796 <1012112796@qq.com> | 2020-11-28 23:52:29 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-28 17:52:29 +0200 |
commit | 1e5247d424de7f8a480c73b0b72119ae5482edf1 (patch) | |
tree | 350de4758a29357766273d049bc830535448e5d4 /models/repo_permission.go | |
parent | 48c9865fce915c28fe3759cfb1b75c65feac2f55 (diff) | |
download | gitea-1e5247d424de7f8a480c73b0b72119ae5482edf1.tar.gz gitea-1e5247d424de7f8a480c73b0b72119ae5482edf1.zip |
ui: show 'owner' tag for real owner (#13689)
* ui: show 'owner' tag for real owner
Signed-off-by: a1012112796 <1012112796@qq.com>
* Update custom/conf/app.example.ini
* simplify logic
fix logic
fix a small bug about original author
* remove system manager tag
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'models/repo_permission.go')
-rw-r--r-- | models/repo_permission.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/models/repo_permission.go b/models/repo_permission.go index 7768bb6257..138613b2e9 100644 --- a/models/repo_permission.go +++ b/models/repo_permission.go @@ -271,6 +271,27 @@ func getUserRepoPermission(e Engine, repo *Repository, user *User) (perm Permiss return } +// IsUserRealRepoAdmin check if this user is real repo admin +func IsUserRealRepoAdmin(repo *Repository, user *User) (bool, error) { + if repo.OwnerID == user.ID { + return true, nil + } + + sess := x.NewSession() + defer sess.Close() + + if err := repo.getOwner(sess); err != nil { + return false, err + } + + accessMode, err := accessLevel(sess, user, repo) + if err != nil { + return false, err + } + + return accessMode >= AccessModeAdmin, nil +} + // IsUserRepoAdmin return true if user has admin right of a repo func IsUserRepoAdmin(repo *Repository, user *User) (bool, error) { return isUserRepoAdmin(x, repo, user) |