summaryrefslogtreecommitdiffstats
path: root/routers/user
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-02-14 19:57:49 -0500
committerUnknwon <u@gogs.io>2016-02-14 19:57:49 -0500
commitdaa43cfb6e6ed4118676e55d47d8816bab2379e5 (patch)
treed6351fee390e01939ead499729ac5c52d1209026 /routers/user
parent9adfe453d506fa7ea18b2df3871f72b5c4dc9b7c (diff)
parent45db167f7a80f777db403decf9532bc9a6c9d43e (diff)
downloadgitea-daa43cfb6e6ed4118676e55d47d8816bab2379e5.tar.gz
gitea-daa43cfb6e6ed4118676e55d47d8816bab2379e5.zip
Merge pull request #2567 from fnkr/hide-other-teams-activity-from-dashboard
Only show activities and repositories on the dashboard, that the user has access to
Diffstat (limited to 'routers/user')
-rw-r--r--routers/user/home.go26
-rw-r--r--routers/user/profile.go2
2 files changed, 19 insertions, 9 deletions
diff --git a/routers/user/home.go b/routers/user/home.go
index 61cda33be2..d48f28316e 100644
--- a/routers/user/home.go
+++ b/routers/user/home.go
@@ -51,8 +51,8 @@ func getDashboardContextUser(ctx *middleware.Context) *models.User {
return ctxUser
}
-func retrieveFeeds(ctx *middleware.Context, uid, offset int64, isProfile bool) {
- actions, err := models.GetFeeds(uid, offset, isProfile)
+func retrieveFeeds(ctx *middleware.Context, ctxUserID, userID, offset int64, isProfile bool) {
+ actions, err := models.GetFeeds(ctxUserID, userID, offset, isProfile)
if err != nil {
ctx.Handle(500, "GetFeeds", err)
return
@@ -109,10 +109,20 @@ func Dashboard(ctx *middleware.Context) {
ctx.Data["CollaborativeRepos"] = collaborateRepos
}
- repos, err := models.GetRepositories(ctxUser.Id, true)
- if err != nil {
- ctx.Handle(500, "GetRepositories", err)
- return
+ var repos []*models.Repository
+ if ctxUser.IsOrganization() {
+ if err := ctxUser.GetUserRepositories(ctx.User.Id); err != nil {
+ ctx.Handle(500, "GetUserRepositories", err)
+ return
+ }
+ repos = ctxUser.Repos
+ } else {
+ var err error
+ repos, err = models.GetRepositories(ctxUser.Id, true)
+ if err != nil {
+ ctx.Handle(500, "GetRepositories", err)
+ return
+ }
}
ctx.Data["Repos"] = repos
@@ -120,7 +130,7 @@ func Dashboard(ctx *middleware.Context) {
mirrors := make([]*models.Repository, 0, 5)
for _, repo := range repos {
if repo.IsMirror {
- if err = repo.GetMirror(); err != nil {
+ if err := repo.GetMirror(); err != nil {
ctx.Handle(500, "GetMirror: "+repo.Name, err)
return
}
@@ -130,7 +140,7 @@ func Dashboard(ctx *middleware.Context) {
ctx.Data["MirrorCount"] = len(mirrors)
ctx.Data["Mirrors"] = mirrors
- retrieveFeeds(ctx, ctxUser.Id, 0, false)
+ retrieveFeeds(ctx, ctx.User.Id, ctxUser.Id, 0, false)
if ctx.Written() {
return
}
diff --git a/routers/user/profile.go b/routers/user/profile.go
index 0a876610ed..c1ebc3bf83 100644
--- a/routers/user/profile.go
+++ b/routers/user/profile.go
@@ -86,7 +86,7 @@ func Profile(ctx *middleware.Context) {
ctx.Data["TabName"] = tab
switch tab {
case "activity":
- retrieveFeeds(ctx, u.Id, 0, true)
+ retrieveFeeds(ctx, -1, u.Id, 0, true)
if ctx.Written() {
return
}