mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
add sessions to API.
This commit is contained in:
@ -45,6 +45,7 @@ func (api *ApiManagerCtx) Route(r types.Router) {
|
||||
|
||||
r.Post("/logout", api.Logout)
|
||||
r.Get("/whoami", api.Whoami)
|
||||
r.Get("/sessions", api.Sessions)
|
||||
|
||||
membersHandler := members.New(api.members)
|
||||
r.Route("/members", membersHandler.Route)
|
||||
|
@ -81,3 +81,16 @@ func (api *ApiManagerCtx) Whoami(w http.ResponseWriter, r *http.Request) error {
|
||||
State: session.State(),
|
||||
})
|
||||
}
|
||||
|
||||
func (api *ApiManagerCtx) Sessions(w http.ResponseWriter, r *http.Request) error {
|
||||
sessions := []SessionDataPayload{}
|
||||
for _, session := range api.sessions.List() {
|
||||
sessions = append(sessions, SessionDataPayload{
|
||||
ID: session.ID(),
|
||||
Profile: session.Profile(),
|
||||
State: session.State(),
|
||||
})
|
||||
}
|
||||
|
||||
return utils.HttpSuccess(w, sessions)
|
||||
}
|
||||
|
Reference in New Issue
Block a user