diff --git a/common/responses.go b/common/responses.go index 390a3fd..8063565 100644 --- a/common/responses.go +++ b/common/responses.go @@ -92,7 +92,7 @@ type ResponseMsgUsers struct { } type ResponseMsgUser struct { - User UserResponse `json:"user"` + User `json:"user"` } type ResponseMsgScenarios struct { diff --git a/routes/user/user_endpoints.go b/routes/user/user_endpoints.go index 564830b..fd442dc 100644 --- a/routes/user/user_endpoints.go +++ b/routes/user/user_endpoints.go @@ -1,12 +1,14 @@ package user import ( + "encoding/json" "fmt" - "github.com/dgrijalva/jwt-go" - "github.com/gin-gonic/gin" "net/http" "time" + "github.com/dgrijalva/jwt-go" + "github.com/gin-gonic/gin" + "git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/common" ) @@ -124,13 +126,20 @@ func authenticate(c *gin.Context) { return } - serializer := common.UserSerializer{c, user.User} + response, err := json.Marshal(common.ResponseMsgUser{user.User}) + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{ + "success": false, + "message": fmt.Sprintf("%v", err), + }) + return + } c.JSON(http.StatusOK, gin.H{ "success": true, "message": "Authenticated", "token": tokenString, - "user": serializer.Response(false), + "user": response, }) } @@ -380,9 +389,17 @@ func getUser(c *gin.Context) { return } - serializer := common.UserSerializer{c, user.User} + response, err := json.Marshal(common.ResponseMsgUser{user.User}) + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{ + "success": false, + "message": fmt.Sprintf("%v", err), + }) + return + } + c.JSON(http.StatusOK, gin.H{ - "user": serializer.Response(false), + "user": response, }) }