memberships: Return user public keys from /api/users
Change-Id: I82ffc7d396c2775aee07e04aeaab757615a258b0
diff --git a/core/auth/memberships/main.go b/core/auth/memberships/main.go
index 8322933..942846f 100644
--- a/core/auth/memberships/main.go
+++ b/core/auth/memberships/main.go
@@ -55,6 +55,7 @@
Id string `json:"id"`
Username string `json:"username"`
Email string `json:"email"`
+ SSHPublicKeys []string `json:"sshPublicKeys,omitempty"`
}
func getLoggedInUser(r *http.Request) (string, error) {
@@ -696,6 +697,14 @@
http.Error(w, "Failed to retrieve user infos", http.StatusInternalServerError)
return
}
+ for i, user := range users {
+ sshKeys, err := s.store.GetUserPublicKeys(nil, user.Id)
+ if err != nil {
+ http.Error(w, "Failed to retrieve user infos", http.StatusInternalServerError)
+ return
+ }
+ users[i].SSHPublicKeys = sshKeys
+ }
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(users); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)