diff options
Diffstat (limited to 'models')
-rw-r--r-- | models/access.go | 5 | ||||
-rw-r--r-- | models/login.go | 1 | ||||
-rw-r--r-- | models/migrations/migrations.go | 8 | ||||
-rw-r--r-- | models/repo.go | 19 |
4 files changed, 25 insertions, 8 deletions
diff --git a/models/access.go b/models/access.go index ea2f7f7b..dd856afb 100644 --- a/models/access.go +++ b/models/access.go @@ -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 { diff --git a/models/login.go b/models/login.go index 5e5fbf43..916e2731 100644 --- a/models/login.go +++ b/models/login.go @@ -242,6 +242,7 @@ func LoginUserLdapSource(u *User, name, passwd string, sourceId int64, cfg *LDAP } u = &User{ + LowerName: strings.ToLower(name), Name: name, FullName: fn + " " + sn, LoginType: LDAP, diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 4b5f5a69..94cab453 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -50,10 +50,10 @@ type Version struct { // If you want to "retire" a migration, remove it from the top of the list and // update _MIN_VER_DB accordingly var migrations = []Migration{ - NewMigration("generate collaboration from access", accessToCollaboration), // V0 -> V1 - NewMigration("make authorize 4 if team is owners", ownerTeamUpdate), // V1 -> V2 - NewMigration("refactor access table to use id's", accessRefactor), // V2 -> V3 - NewMigration("generate team-repo from team", teamToTeamRepo), // V3 -> V4 + NewMigration("generate collaboration from access", accessToCollaboration), // V0 -> V1:v0.5.13 + NewMigration("make authorize 4 if team is owners", ownerTeamUpdate), // V1 -> V2:v0.5.13 + NewMigration("refactor access table to use id's", accessRefactor), // V2 -> V3:v0.5.13 + NewMigration("generate team-repo from team", teamToTeamRepo), // V3 -> V4:v0.5.13 } // Migrate database to current version diff --git a/models/repo.go b/models/repo.go index cfab329b..5412ca8f 100644 --- a/models/repo.go +++ b/models/repo.go @@ -104,8 +104,8 @@ func NewRepoContext() { log.Fatal(4, "Gogs requires Git version greater or equal to 1.7.1") } - // Check if server has user.email and user.name set correctly and set if they're not. - for configKey, defaultValue := range map[string]string{"user.name": "Gogs", "user.email": "gogitservice@gmail.com"} { + // Git requires setting user.name and user.email in order to commit changes. + for configKey, defaultValue := range map[string]string{"user.name": "Gogs", "user.email": "gogs@fake.local"} { if stdout, stderr, err := process.Exec("NewRepoContext(get setting)", "git", "config", "--get", configKey); err != nil || strings.TrimSpace(stdout) == "" { // ExitError indicates this config is not set if _, ok := err.(*exec.ExitError); ok || strings.TrimSpace(stdout) == "" { @@ -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() |