aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/v1/user/star.go
diff options
context:
space:
mode:
authorEthan Koenig <ethantkoenig@gmail.com>2016-12-05 18:48:51 -0500
committerKim "BKC" Carlbäcker <kim.carlbacker@gmail.com>2016-12-07 12:55:24 +0100
commit04b9a7e7a22d968790aeee9c316391252b0aaf67 (patch)
treeeb7af4ff5dbe06439511779331aac0b2de3a8c04 /routers/api/v1/user/star.go
parent08b9af9ad8861352d1b68d15b33ef265352a2f4a (diff)
downloadgitea-04b9a7e7a22d968790aeee9c316391252b0aaf67.tar.gz
gitea-04b9a7e7a22d968790aeee9c316391252b0aaf67.zip
Bug fixes for repo permissions in API
Also move duplicated code into repo.APIFormat(..)
Diffstat (limited to 'routers/api/v1/user/star.go')
-rw-r--r--routers/api/v1/user/star.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/routers/api/v1/user/star.go b/routers/api/v1/user/star.go
index c856ecefdd..0937fd1903 100644
--- a/routers/api/v1/user/star.go
+++ b/routers/api/v1/user/star.go
@@ -18,9 +18,17 @@ func getStarredRepos(userID int64, private bool) ([]*api.Repository, error) {
if err != nil {
return nil, err
}
+ user, err := models.GetUserByID(userID)
+ if err != nil {
+ return nil, err
+ }
repos := make([]*api.Repository, len(starredRepos))
for i, starred := range starredRepos {
- repos[i] = starred.APIFormat(&api.Permission{true, true, true})
+ access, err := models.AccessLevel(user, starred)
+ if err != nil {
+ return nil, err
+ }
+ repos[i] = starred.APIFormat(access)
}
return repos, nil
}