Accounts admin view/get api

This commit is contained in:
Torkel Ödegaard 2015-01-15 15:54:22 +01:00
parent fdfcc3ab2a
commit 804bff55ec
4 changed files with 8 additions and 6 deletions

@ -1 +1 @@
Subproject commit cf344abff2cdf7638d1748aa698caf23c3848715 Subproject commit 5b93e09714dbee6c1c181daf0182704334d8c6be

View File

@ -10,7 +10,7 @@ import (
// Register adds http routes // Register adds http routes
func Register(m *macaron.Macaron) { func Register(m *macaron.Macaron) {
reqSignedIn := middleware.Auth(&middleware.AuthOptions{ReqSignedIn: true}) reqSignedIn := middleware.Auth(&middleware.AuthOptions{ReqSignedIn: true})
reqAdmin := middleware.Auth(&middleware.AuthOptions{ReqSignedIn: true, ReqAdmin: false}) reqAdmin := middleware.Auth(&middleware.AuthOptions{ReqSignedIn: true, ReqAdmin: true})
// not logged in views // not logged in views
m.Get("/", reqSignedIn, Index) m.Get("/", reqSignedIn, Index)

View File

@ -97,7 +97,9 @@ type CollaboratorDTO struct {
type AccountSearchHitDTO struct { type AccountSearchHitDTO struct {
Id int64 `json:"id"` Id int64 `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Login string `json:"login"`
Email string `json:"email"` Email string `json:"email"`
IsAdmin bool `json:"isAdmin"`
} }
type AccountDTO struct { type AccountDTO struct {

View File

@ -188,7 +188,7 @@ func SearchAccounts(query *m.SearchAccountsQuery) error {
sess := x.Table("account") sess := x.Table("account")
sess.Where("email LIKE ?", query.Query+"%") sess.Where("email LIKE ?", query.Query+"%")
sess.Limit(query.Limit, query.Limit*query.Page) sess.Limit(query.Limit, query.Limit*query.Page)
sess.Cols("id", "email", "name") sess.Cols("id", "email", "name", "login", "is_admin")
err := sess.Find(&query.Result) err := sess.Find(&query.Result)
return err return err