🐛 Fix userinfo endpoint mismatch oidc
All checks were successful
release-nightly / build-docker (push) Successful in 3m23s

This commit is contained in:
LittleSheep 2024-01-30 21:34:48 +08:00
parent c5126bc4db
commit 997ada9da6

View File

@ -6,6 +6,7 @@ import (
"code.smartsheep.studio/hydrogen/passport/pkg/services"
"fmt"
"github.com/gofiber/fiber/v2"
jsoniter "github.com/json-iterator/go"
"github.com/spf13/viper"
)
@ -24,7 +25,18 @@ func getPrincipal(c *fiber.Ctx) error {
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
}
return c.JSON(data)
var resp fiber.Map
raw, _ := jsoniter.Marshal(data)
jsoniter.Unmarshal(raw, &resp)
resp["sub"] = data.ID
resp["family_name"] = data.Profile.FirstName
resp["given_name"] = data.Profile.LastName
resp["name"] = data.Name
resp["email"] = data.GetPrimaryEmail().Content
resp["preferred_username"] = data.Nick
return c.JSON(resp)
}
func getEvents(c *fiber.Ctx) error {