Browse Source

fix #1997

pull/1694/head
Unknwon 9 years ago
parent
commit
2158e6fc43
  1. 2
      gogs.go
  2. 20
      models/access.go
  3. 2
      modules/middleware/repo.go
  4. 2
      templates/.VERSION

2
gogs.go

@ -17,7 +17,7 @@ import (
"github.com/gogits/gogs/modules/setting" "github.com/gogits/gogs/modules/setting"
) )
const APP_VER = "0.7.18.1118 Beta" const APP_VER = "0.7.18.1119 Beta"
func init() { func init() {
runtime.GOMAXPROCS(runtime.NumCPU()) runtime.GOMAXPROCS(runtime.NumCPU())

20
models/access.go

@ -36,19 +36,19 @@ func accessLevel(e Engine, u *User, repo *Repository) (AccessMode, error) {
mode = ACCESS_MODE_READ mode = ACCESS_MODE_READ
} }
if u != nil { if u == nil {
if u.Id == repo.OwnerID { return mode, nil
return ACCESS_MODE_OWNER, nil }
}
a := &Access{UserID: u.Id, RepoID: repo.ID} if u.Id == repo.OwnerID {
if has, err := e.Get(a); !has || err != nil { return ACCESS_MODE_OWNER, nil
return mode, err
}
return a.Mode, nil
} }
return mode, nil a := &Access{UserID: u.Id, RepoID: repo.ID}
if has, err := e.Get(a); !has || err != nil {
return mode, err
}
return a.Mode, nil
} }
// AccessLevel returns the Access a user has to a repository. Will return NoneAccess if the // AccessLevel returns the Access a user has to a repository. Will return NoneAccess if the

2
modules/middleware/repo.go

@ -275,7 +275,7 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler {
} }
// Admin has super access. // Admin has super access.
if ctx.User.IsAdmin { if ctx.IsSigned && ctx.User.IsAdmin {
ctx.Repo.AccessMode = models.ACCESS_MODE_OWNER ctx.Repo.AccessMode = models.ACCESS_MODE_OWNER
} else { } else {
mode, err := models.AccessLevel(ctx.User, repo) mode, err := models.AccessLevel(ctx.User, repo)

2
templates/.VERSION

@ -1 +1 @@
0.7.18.1118 Beta 0.7.18.1119 Beta
Loading…
Cancel
Save