fixed issue with Role not being returned when getting repo

This commit is contained in:
Brad Rydzewski 2014-10-08 21:28:06 -07:00
parent bb218a6268
commit 962aa8e968

View file

@ -22,14 +22,13 @@ import (
// //
func GetRepo(c web.C, w http.ResponseWriter, r *http.Request) { func GetRepo(c web.C, w http.ResponseWriter, r *http.Request) {
var ( var (
admin = r.FormValue("admin") role = ToRole(c)
role = ToRole(c) repo = ToRepo(c)
repo = ToRepo(c)
) )
// if the user is not requesting (or cannot access) // if the user is not requesting (or cannot access)
// admin data then we just return the repo as-is // admin data then we just return the repo as-is
if len(admin) == 0 || role.Admin == false { if role.Admin == false {
json.NewEncoder(w).Encode(repo) json.NewEncoder(w).Encode(repo)
return return
} }
@ -37,9 +36,10 @@ func GetRepo(c web.C, w http.ResponseWriter, r *http.Request) {
// else we should return restricted fields // else we should return restricted fields
json.NewEncoder(w).Encode(struct { json.NewEncoder(w).Encode(struct {
*model.Repo *model.Repo
PublicKey string `json:"public_key"` PublicKey string `json:"public_key"`
Params string `json:"params"` Params string `json:"params"`
}{repo, repo.PublicKey, repo.Params}) Perm *model.Perm `json:"role"`
}{repo, repo.PublicKey, repo.Params, role})
} }
// DelRepo accepts a request to inactivate the named // DelRepo accepts a request to inactivate the named