summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-02-23 00:14:45 +0800
committertechknowlogick <matti@mdranta.net>2019-02-22 11:14:45 -0500
commit134e55510eda8c3c6d61da18ee97e3243c6e3bc2 (patch)
tree6f0f2f6b99d4b5fb805c0425d3129101fadea8e6 /models
parentdf30010dbdd2c9479aee292f5759b85143558498 (diff)
downloadgitea-134e55510eda8c3c6d61da18ee97e3243c6e3bc2.tar.gz
gitea-134e55510eda8c3c6d61da18ee97e3243c6e3bc2.zip
fix bug when update owner team then visit team's repo return 404 (#6119)
Diffstat (limited to 'models')
-rw-r--r--models/repo_permission.go9
-rw-r--r--models/repo_permission_test.go11
2 files changed, 20 insertions, 0 deletions
diff --git a/models/repo_permission.go b/models/repo_permission.go
index 9dd7cc559d..418cd77f2d 100644
--- a/models/repo_permission.go
+++ b/models/repo_permission.go
@@ -151,6 +151,15 @@ func getUserRepoPermission(e Engine, repo *Repository, user *User) (perm Permiss
return
}
+ // if user in an owner team
+ for _, team := range teams {
+ if team.Authorize >= AccessModeOwner {
+ perm.AccessMode = AccessModeOwner
+ perm.UnitsMode = nil
+ return
+ }
+ }
+
for _, u := range repo.Units {
var found bool
for _, team := range teams {
diff --git a/models/repo_permission_test.go b/models/repo_permission_test.go
index fd55ae5e52..0f350e62aa 100644
--- a/models/repo_permission_test.go
+++ b/models/repo_permission_test.go
@@ -219,6 +219,17 @@ func TestRepoPermissionPrivateOrgRepo(t *testing.T) {
assert.True(t, perm.CanWrite(unit.Type))
}
+ // update team information and then check permission
+ team := AssertExistsAndLoadBean(t, &Team{ID: 5}).(*Team)
+ err = UpdateTeamUnits(team, nil)
+ assert.NoError(t, err)
+ perm, err = GetUserRepoPermission(repo, owner)
+ assert.NoError(t, err)
+ for _, unit := range repo.Units {
+ assert.True(t, perm.CanRead(unit.Type))
+ assert.True(t, perm.CanWrite(unit.Type))
+ }
+
// org member team tester
tester := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
perm, err = GetUserRepoPermission(repo, tester)