mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-22 09:13:10 +00:00
#1143 Team member access lost when adding repository collaborator
- fix bug when add a repo to team, all other team members gets access as well
This commit is contained in:
parent
ab6b288141
commit
6f81c05dde
4 changed files with 20 additions and 4 deletions
2
gogs.go
2
gogs.go
|
@ -17,7 +17,7 @@ import (
|
|||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
const APP_VER = "0.6.0.0323 Beta"
|
||||
const APP_VER = "0.6.1.0324 Beta"
|
||||
|
||||
func init() {
|
||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||
|
|
|
@ -170,8 +170,13 @@ func (repo *Repository) recalculateTeamAccesses(e Engine, ignTeamID int64) (err
|
|||
if t.ID == ignTeamID {
|
||||
continue
|
||||
}
|
||||
|
||||
// Owner team gets owner access, and skip for teams that do not
|
||||
// have relations with repository.
|
||||
if t.IsOwnerTeam() {
|
||||
t.Authorize = ACCESS_MODE_OWNER
|
||||
} else if !t.hasRepository(e, repo.Id) {
|
||||
continue
|
||||
}
|
||||
|
||||
if err = t.getMembers(e); err != nil {
|
||||
|
|
|
@ -1107,6 +1107,10 @@ func (repo *Repository) AddCollaborator(u *User) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
if err = repo.GetOwner(); err != nil {
|
||||
return fmt.Errorf("GetOwner: %v", err)
|
||||
}
|
||||
|
||||
sess := x.NewSession()
|
||||
defer sessionRelease(sess)
|
||||
if err = sess.Begin(); err != nil {
|
||||
|
@ -1115,8 +1119,15 @@ func (repo *Repository) AddCollaborator(u *User) error {
|
|||
|
||||
if _, err = sess.InsertOne(collaboration); err != nil {
|
||||
return err
|
||||
} else if err = repo.recalculateAccesses(sess); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if repo.Owner.IsOrganization() {
|
||||
err = repo.recalculateTeamAccesses(sess, 0)
|
||||
} else {
|
||||
err = repo.recalculateAccesses(sess)
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("recalculateAccesses 'team=%v': %v", repo.Owner.IsOrganization(), err)
|
||||
}
|
||||
|
||||
return sess.Commit()
|
||||
|
|
|
@ -1 +1 @@
|
|||
0.6.0.0323 Beta
|
||||
0.6.1.0324 Beta
|
Loading…
Reference in a new issue