mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-21 17:24:10 +00:00
Safe work
This commit is contained in:
parent
f1d8746264
commit
83283bca4c
6 changed files with 40 additions and 16 deletions
|
@ -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{}{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue