]> source.dussan.org Git - gitea.git/commitdiff
fix bug when update owner team then visit team's repo return 404 (#6119) (#6166)
authorLunny Xiao <xiaolunwen@gmail.com>
Sat, 23 Feb 2019 03:55:32 +0000 (11:55 +0800)
committertechknowlogick <matti@mdranta.net>
Sat, 23 Feb 2019 03:55:32 +0000 (22:55 -0500)
models/repo_permission.go
models/repo_permission_test.go
routers/org/teams.go

index 9dd7cc559d2c99935c877622840cc49eb980d0ff..418cd77f2dc776638203f1eb3da9171e277fa266 100644 (file)
@@ -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 {
index fd55ae5e5241279a8afa3b56aa8e8e8c13350302..0f350e62aad98f29675f2e2c46c568bc2609f70b 100644 (file)
@@ -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)
index 80309dff4490427f4def1644d2859387546acfe9..1c0973799718224046ac0654b78cd89bfe81aa4e 100644 (file)
@@ -288,8 +288,6 @@ func EditTeamPost(ctx *context.Context, form auth.CreateTeamForm) {
                        })
                }
                models.UpdateTeamUnits(t, units)
-       } else {
-               models.UpdateTeamUnits(t, nil)
        }
 
        if ctx.HasError() {