✨ User info
This commit is contained in:
@ -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
|
||||
|
12
pkg/server/profiles_api.go
Normal file
12
pkg/server/profiles_api.go
Normal 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)
|
||||
}
|
@ -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)
|
||||
|
Reference in New Issue
Block a user