diff options
author | 无闻 <u@gogs.io> | 2015-02-23 13:51:02 -0500 |
---|---|---|
committer | 无闻 <u@gogs.io> | 2015-02-23 13:51:02 -0500 |
commit | f92bfabf864bf7fae19777a537986fffcef0c873 (patch) | |
tree | 6886de30f2eabcab2dea3b9ac93b1838a75cbe95 | |
parent | ee68a826a55c6a4305e7f609db57501a54a5bc47 (diff) | |
parent | 0fa209d07b6155943bfd235257a4ed6a484a9a85 (diff) | |
download | gitea-f92bfabf864bf7fae19777a537986fffcef0c873.tar.gz gitea-f92bfabf864bf7fae19777a537986fffcef0c873.zip |
Merge pull request #960 from phsmit/access_action
Fix that owners also see actions on their repositories
-rw-r--r-- | routers/user/home.go | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/routers/user/home.go b/routers/user/home.go index 35407534f9..0a1d9dd217 100644 --- a/routers/user/home.go +++ b/routers/user/home.go @@ -103,9 +103,14 @@ func Dashboard(ctx *middleware.Context) { feeds := make([]*models.Action, 0, len(actions)) for _, act := range actions { if act.IsPrivate { - if has, _ := models.HasAccess(ctx.User, &models.Repository{Id: act.RepoId, IsPrivate: true}, models.ACCESS_MODE_READ); !has { - continue + // This prevents having to retrieve the repository for each action + repo := &models.Repository{Id: act.RepoId, IsPrivate: true} + if act.RepoUserName != ctx.User.LowerName { + if has, _ := models.HasAccess(ctx.User, repo, models.ACCESS_MODE_READ); !has { + continue + } } + } // FIXME: cache results? u, err := models.GetUserByName(act.ActUserName) @@ -210,13 +215,14 @@ func Profile(ctx *middleware.Context) { if !ctx.IsSigned { continue } - if has, _ := models.HasAccess(ctx.User, - &models.Repository{ - Id: act.RepoId, - IsPrivate: true, - }, models.ACCESS_MODE_READ); !has { - continue + // This prevents having to retrieve the repository for each action + repo := &models.Repository{Id: act.RepoId, IsPrivate: true} + if act.RepoUserName != ctx.User.LowerName { + if has, _ := models.HasAccess(ctx.User, repo, models.ACCESS_MODE_READ); !has { + continue + } } + } // FIXME: cache results? u, err := models.GetUserByName(act.ActUserName) |