mirror of https://github.com/go-gitea/gitea.git
fix bug when update owner team then visit team's repo return 404 (#6119)
This commit is contained in:
parent
df30010dbd
commit
134e55510e
|
@ -151,6 +151,15 @@ func getUserRepoPermission(e Engine, repo *Repository, user *User) (perm Permiss
|
||||||
return
|
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 {
|
for _, u := range repo.Units {
|
||||||
var found bool
|
var found bool
|
||||||
for _, team := range teams {
|
for _, team := range teams {
|
||||||
|
|
|
@ -219,6 +219,17 @@ func TestRepoPermissionPrivateOrgRepo(t *testing.T) {
|
||||||
assert.True(t, perm.CanWrite(unit.Type))
|
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
|
// org member team tester
|
||||||
tester := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
|
tester := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
|
||||||
perm, err = GetUserRepoPermission(repo, tester)
|
perm, err = GetUserRepoPermission(repo, tester)
|
||||||
|
|
|
@ -288,8 +288,6 @@ func EditTeamPost(ctx *context.Context, form auth.CreateTeamForm) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
models.UpdateTeamUnits(t, units)
|
models.UpdateTeamUnits(t, units)
|
||||||
} else {
|
|
||||||
models.UpdateTeamUnits(t, nil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctx.HasError() {
|
if ctx.HasError() {
|
||||||
|
|
Loading…
Reference in New Issue