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 {
|
type MemberDataPayload struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
|
Secret string `json:"secret,omitempty"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
IsAdmin bool `json:"is_admin"`
|
IsAdmin bool `json:"is_admin"`
|
||||||
//Enabled bool `json:"enabled"`
|
//Enabled bool `json:"enabled"`
|
||||||
@ -27,26 +28,24 @@ func (h *MembersHandler) membersCreate(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
session, err := h.sessions.Create(types.MemberProfile{
|
id, err := utils.NewUID(32)
|
||||||
Name: data.Name,
|
|
||||||
IsAdmin: data.IsAdmin,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.HttpInternalServer(w, err)
|
utils.HttpInternalServer(w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
session := h.sessions.Create(id, types.MemberProfile{
|
||||||
|
Secret: data.Secret,
|
||||||
|
Name: data.Name,
|
||||||
|
IsAdmin: data.IsAdmin,
|
||||||
|
})
|
||||||
|
|
||||||
utils.HttpSuccess(w, MemberCreatePayload{
|
utils.HttpSuccess(w, MemberCreatePayload{
|
||||||
ID: session.ID(),
|
ID: session.ID(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *MembersHandler) membersRead(w http.ResponseWriter, r *http.Request) {
|
func (h *MembersHandler) membersRead(w http.ResponseWriter, r *http.Request) {
|
||||||
data := &MemberDataPayload{}
|
|
||||||
if !utils.HttpJsonRequest(w, r, data) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
member := GetMember(r)
|
member := GetMember(r)
|
||||||
|
|
||||||
utils.HttpSuccess(w, MemberDataPayload{
|
utils.HttpSuccess(w, MemberDataPayload{
|
||||||
|
Loading…
Reference in New Issue
Block a user