1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-06 17:41:00 +00:00

Add API endpoint to get logged user

This commit is contained in:
Leviathan Jeanis 2018-05-14 18:41:41 -07:00 committed by Frédéric Guillot
parent 4674d559a4
commit e81e4f0ac3
2 changed files with 14 additions and 1 deletions

View file

@ -13,6 +13,18 @@ import (
"github.com/miniflux/miniflux/http/response/json"
)
// CurrentUser is the API handler to retrieve the authenticated user.
func (c *Controller) CurrentUser(w http.ResponseWriter, r *http.Request) {
ctx := context.New(r)
user, err := c.store.UserByID(ctx.UserID())
if err != nil {
json.ServerError(w, err)
return
}
json.OK(w, user)
}
// CreateUser is the API handler to create a new user.
func (c *Controller) CreateUser(w http.ResponseWriter, r *http.Request) {
ctx := context.New(r)