diff options
author | Unknown <joe2010xtmf@163.com> | 2014-05-08 12:24:11 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-05-08 12:24:11 -0400 |
commit | e86728340654b18a657a65920c16e28a1b00cca7 (patch) | |
tree | 5ef13e753aef6fab75c78fac703945fe0938fd03 /modules | |
parent | a03f380fa86f83f35a5636535ec3002100b335bb (diff) | |
download | gitea-e86728340654b18a657a65920c16e28a1b00cca7.tar.gz gitea-e86728340654b18a657a65920c16e28a1b00cca7.zip |
Assignee back end
Diffstat (limited to 'modules')
-rw-r--r-- | modules/middleware/repo.go | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go index 7d0cc97970..53d4dae4f8 100644 --- a/modules/middleware/repo.go +++ b/modules/middleware/repo.go @@ -21,6 +21,7 @@ import ( func RepoAssignment(redirect bool, args ...bool) martini.Handler { return func(ctx *Context, params martini.Params) { + log.Trace(fmt.Sprint(args)) // valid brachname var validBranch bool // display bare quick start if it is a bare repo @@ -38,29 +39,36 @@ func RepoAssignment(redirect bool, args ...bool) martini.Handler { } var ( - user *models.User - err error + user *models.User + err error + isTrueOwner bool ) userName := params["username"] repoName := params["reponame"] refName := params["branchname"] - // TODO: check collaborators - // get repository owner - ctx.Repo.IsOwner = ctx.IsSigned && ctx.User.LowerName == strings.ToLower(userName) + // Collaborators who have write access can be seen as owners. + if ctx.IsSigned { + ctx.Repo.IsOwner, err = models.HasAccess(ctx.User.Name, repoName, models.AU_WRITABLE) + if err != nil { + ctx.Handle(500, "RepoAssignment(HasAccess)", err) + return + } + isTrueOwner = ctx.User.LowerName == strings.ToLower(userName) + } - if !ctx.Repo.IsOwner { - user, err = models.GetUserByName(params["username"]) + if !isTrueOwner { + user, err = models.GetUserByName(userName) if err != nil { if err == models.ErrUserNotExist { - ctx.Handle(404, "RepoAssignment", err) + ctx.Handle(404, "RepoAssignment(GetUserByName)", err) return } else if redirect { ctx.Redirect("/") return } - ctx.Handle(500, "RepoAssignment", err) + ctx.Handle(500, "RepoAssignment(GetUserByName)", err) return } } else { |