diff options
author | Ethan Koenig <ethantkoenig@gmail.com> | 2016-12-05 18:48:51 -0500 |
---|---|---|
committer | Kim "BKC" Carlbäcker <kim.carlbacker@gmail.com> | 2016-12-07 12:55:24 +0100 |
commit | 04b9a7e7a22d968790aeee9c316391252b0aaf67 (patch) | |
tree | eb7af4ff5dbe06439511779331aac0b2de3a8c04 /routers/api/v1/user/star.go | |
parent | 08b9af9ad8861352d1b68d15b33ef265352a2f4a (diff) | |
download | gitea-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.go | 10 |
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 } |