From fabde2473461f11c0ba0cdb53454500dad4fc218 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Tue, 28 Jan 2025 19:27:48 +0800 Subject: [PATCH] :bug: Trying to fix factor respond with null config --- pkg/internal/http/api/factors_api.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/internal/http/api/factors_api.go b/pkg/internal/http/api/factors_api.go index cc87fdd..6469269 100644 --- a/pkg/internal/http/api/factors_api.go +++ b/pkg/internal/http/api/factors_api.go @@ -8,6 +8,7 @@ import ( "git.solsynth.dev/hypernet/passport/pkg/internal/http/exts" "git.solsynth.dev/hypernet/passport/pkg/internal/services" "github.com/gofiber/fiber/v2" + jsoniter "github.com/json-iterator/go" "github.com/pquerna/otp/totp" "github.com/samber/lo" "github.com/spf13/viper" @@ -142,7 +143,12 @@ func createFactor(c *fiber.Ctx) error { factor.Config = datatypes.NewJSONType(data) } - return c.JSON(factor) + var out map[string]any + raw, _ := jsoniter.Marshal(factor) + jsoniter.Unmarshal(raw, &out) + out["config"] = factor.Config.Data() + + return c.JSON(out) } func deleteFactor(c *fiber.Ctx) error {