refactor(server): merge authserver implementation
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type UserHandler struct{}
|
||||
|
||||
func NewUserHandler() *UserHandler {
|
||||
return &UserHandler{}
|
||||
}
|
||||
|
||||
func (h *UserHandler) Me(c *gin.Context) {
|
||||
claims, ok := CurrentClaims(c)
|
||||
if !ok {
|
||||
c.JSON(http.StatusUnauthorized, gin.H{"error": "missing current user"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"id": claims.UserID,
|
||||
"username": claims.Username,
|
||||
"email": claims.Email,
|
||||
"is_admin": claims.IsAdmin,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user