User info

This commit is contained in:
2024-01-28 00:42:02 +08:00
parent 4f33b9e0f6
commit 9b5500305f
9 changed files with 106 additions and 9 deletions

View File

@ -28,6 +28,7 @@ var auth = keyauth.New(keyauth.Config{
return false, err
}
c.Locals("principal", user)
c.Locals("permissions", user.Permissions.Data())
return true, nil

View File

@ -0,0 +1,12 @@
package server
import (
"code.smartsheep.studio/hydrogen/passport/pkg/models"
"github.com/gofiber/fiber/v2"
)
func aboutMe(c *fiber.Ctx) error {
user := c.Locals("principal").(models.Account)
return c.JSON(user)
}

View File

@ -21,6 +21,7 @@ func NewServer() {
api := A.Group("/api").Name("API")
{
api.Get("/users/me", auth, aboutMe)
api.Post("/users", doRegister)
api.Put("/auth", startChallenge)