Deprecates common.UserSerializer() from user endpoints

This commit is contained in:
smavros 2019-08-13 15:48:11 +02:00
parent b9d78a3823
commit 50b1902bf3
2 changed files with 24 additions and 7 deletions

View file

@ -92,7 +92,7 @@ type ResponseMsgUsers struct {
}
type ResponseMsgUser struct {
User UserResponse `json:"user"`
User `json:"user"`
}
type ResponseMsgScenarios struct {

View file

@ -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,
})
}