From 997ada9da6fdcfc1a0b68d94ec0205f21fd90cd8 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Tue, 30 Jan 2024 21:34:48 +0800 Subject: [PATCH] :bug: Fix userinfo endpoint mismatch oidc --- pkg/server/accounts_api.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pkg/server/accounts_api.go b/pkg/server/accounts_api.go index 399462d..3f0439f 100644 --- a/pkg/server/accounts_api.go +++ b/pkg/server/accounts_api.go @@ -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 {