From a9eb605b0f3be2f6ae53c47f57baeda35d59f4d5 Mon Sep 17 00:00:00 2001 From: Mason Sun <6109899+sqxccdy@users.noreply.github.com> Date: Sun, 23 Jul 2023 19:11:29 +0800 Subject: [PATCH] fix: auth api json format (#2021) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update auth.go api/v1/auth/相关接口未应用convertUserFromStore方法,会导致User对象获得类型存在问题,导致User定义的`json:`相关的字段转化失效。 导致输出json未被正确格式化 --- api/v1/auth.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/api/v1/auth.go b/api/v1/auth.go index c42e5ab84..7d2b279c2 100644 --- a/api/v1/auth.go +++ b/api/v1/auth.go @@ -65,7 +65,8 @@ func (s *APIV1Service) registerAuthRoutes(g *echo.Group) { if err := s.createAuthSignInActivity(c, user); err != nil { return echo.NewHTTPError(http.StatusInternalServerError, "Failed to create activity").SetInternal(err) } - return c.JSON(http.StatusOK, user) + userMessage := convertUserFromStore(user) + return c.JSON(http.StatusOK, userMessage) }) // POST /auth/signin/sso - Sign in with SSO @@ -152,7 +153,8 @@ func (s *APIV1Service) registerAuthRoutes(g *echo.Group) { if err := s.createAuthSignInActivity(c, user); err != nil { return echo.NewHTTPError(http.StatusInternalServerError, "Failed to create activity").SetInternal(err) } - return c.JSON(http.StatusOK, user) + userMessage := convertUserFromStore(user) + return c.JSON(http.StatusOK, userMessage) }) // POST /auth/signup - Sign up a new user. @@ -218,7 +220,8 @@ func (s *APIV1Service) registerAuthRoutes(g *echo.Group) { return echo.NewHTTPError(http.StatusInternalServerError, "Failed to create activity").SetInternal(err) } - return c.JSON(http.StatusOK, user) + userMessage := convertUserFromStore(user) + return c.JSON(http.StatusOK, userMessage) }) // POST /auth/signout - Sign out.