From 663c28beb61d5c1319665f195b7e2f4f370c3ea9 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Tue, 14 Jul 2015 22:56:02 +0800 Subject: [PATCH] #1279: Removing user from collaboration removes repositiory --- .bra.toml | 4 ++-- models/access.go | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/.bra.toml b/.bra.toml index 426b2e17..fe947215 100644 --- a/.bra.toml +++ b/.bra.toml @@ -14,7 +14,7 @@ watch_exts = [".go"] build_delay = 1500 cmds = [ #["go-bindata", "-o=modules/bindata/bindata.go", "-ignore=\\.DS_Store|README", "-pkg=bindata", "conf/..."], - ["go", "install", "-tags", "sqlite cert"],# redis memcache - ["go", "build", "-tags", "sqlite cert"], + ["go", "install", "-tags", "sqlite"],# redis memcache cert pam + ["go", "build", "-tags", "sqlite"], ["./gogs", "web"] ] \ No newline at end of file diff --git a/models/access.go b/models/access.go index dd856afb..51b60c99 100644 --- a/models/access.go +++ b/models/access.go @@ -145,6 +145,25 @@ func (repo *Repository) refreshCollaboratorAccesses(e Engine, accessMap map[int6 for _, c := range collaborators { accessMap[c.Id] = ACCESS_MODE_WRITE } + + // Adds team members access. + if repo.Owner.IsOrganization() { + if err = repo.Owner.GetTeams(); err != nil { + return fmt.Errorf("GetTeams: %v", err) + } + for _, t := range repo.Owner.Teams { + if err = t.GetMembers(); err != nil { + return fmt.Errorf("GetMembers: %v", err) + } + for _, m := range t.Members { + if t.IsOwnerTeam() { + accessMap[m.Id] = ACCESS_MODE_OWNER + } else { + accessMap[m.Id] = maxAccessMode(accessMap[m.Id], t.Authorize) + } + } + } + } return nil }