diff options
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/v1/repos.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/routers/api/v1/repos.go b/routers/api/v1/repos.go index 37a3e47a63..2dee512f2b 100644 --- a/routers/api/v1/repos.go +++ b/routers/api/v1/repos.go @@ -31,6 +31,26 @@ func SearchRepos(ctx *middleware.Context) { opt.Limit = 10 } + // Check visibility. + if ctx.IsSigned && opt.Uid > 0 { + if ctx.User.Id == opt.Uid { + opt.Private = true + } else { + u, err := models.GetUserById(opt.Uid) + if err != nil { + ctx.JSON(500, map[string]interface{}{ + "ok": false, + "error": err.Error(), + }) + return + } + if u.IsOrganization() && u.IsOrgOwner(ctx.User.Id) { + opt.Private = true + } + // FIXME: how about collaborators? + } + } + repos, err := models.SearchRepositoryByName(opt) if err != nil { ctx.JSON(500, map[string]interface{}{ |