fix: auth api json format (#2021)

Update auth.go

api/v1/auth/相关接口未应用convertUserFromStore方法,会导致User对象获得类型存在问题,导致User定义的`json:`相关的字段转化失效。
导致输出json未被正确格式化
This commit is contained in:
Mason Sun 2023-07-23 19:11:29 +08:00 committed by GitHub
parent 5604129105
commit a9eb605b0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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.