mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
rest CRUD members minor update.
This commit is contained in:
parent
a90bf87e24
commit
59457b7658
@ -13,6 +13,7 @@ type MemberCreatePayload struct {
|
||||
|
||||
type MemberDataPayload struct {
|
||||
ID string `json:"id"`
|
||||
Secret string `json:"secret,omitempty"`
|
||||
Name string `json:"name"`
|
||||
IsAdmin bool `json:"is_admin"`
|
||||
//Enabled bool `json:"enabled"`
|
||||
@ -27,26 +28,24 @@ func (h *MembersHandler) membersCreate(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
session, err := h.sessions.Create(types.MemberProfile{
|
||||
Name: data.Name,
|
||||
IsAdmin: data.IsAdmin,
|
||||
})
|
||||
id, err := utils.NewUID(32)
|
||||
if err != nil {
|
||||
utils.HttpInternalServer(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
session := h.sessions.Create(id, types.MemberProfile{
|
||||
Secret: data.Secret,
|
||||
Name: data.Name,
|
||||
IsAdmin: data.IsAdmin,
|
||||
})
|
||||
|
||||
utils.HttpSuccess(w, MemberCreatePayload{
|
||||
ID: session.ID(),
|
||||
})
|
||||
}
|
||||
|
||||
func (h *MembersHandler) membersRead(w http.ResponseWriter, r *http.Request) {
|
||||
data := &MemberDataPayload{}
|
||||
if !utils.HttpJsonRequest(w, r, data) {
|
||||
return
|
||||
}
|
||||
|
||||
member := GetMember(r)
|
||||
|
||||
utils.HttpSuccess(w, MemberDataPayload{
|
||||
|
Loading…
Reference in New Issue
Block a user