golang-lib/web/auth/api_my_status.go

29 lines
617 B
Go
Raw Permalink Normal View History

2021-06-01 10:51:35 +02:00
package auth
import (
"net/http"
"github.com/gin-gonic/gin"
2023-10-23 21:40:10 +02:00
"codeberg.org/genofire/golang-lib/web"
2021-06-01 10:51:35 +02:00
)
// @Summary Login status
// @Description show user_id and username if logged in
2021-06-30 15:47:24 +02:00
// @Tags auth
2021-06-01 10:51:35 +02:00
// @Accept json
// @Produce json
// @Success 200 {object} User
// @Failure 401 {object} web.HTTPError
// @Failure 500 {object} web.HTTPError
2021-06-30 15:55:34 +02:00
// @Router /api/v1/my/auth/status [get]
// @Security ApiKeyAuth
func apiMyStatus(r *gin.Engine, ws *web.Service) {
r.GET("/api/v1/my/auth/status", MiddlewareLogin(ws), func(c *gin.Context) {
d, ok := GetCurrentUser(c, ws)
if ok {
c.JSON(http.StatusOK, d)
}
2021-06-01 10:51:35 +02:00
})
}