mirror of
https://git.rwth-aachen.de/acs/public/villas/web-backend-go/
synced 2025-03-30 00:00:12 +01:00
Deprecates common.UserSerializer() from user endpoints
This commit is contained in:
parent
b9d78a3823
commit
50b1902bf3
2 changed files with 24 additions and 7 deletions
|
@ -92,7 +92,7 @@ type ResponseMsgUsers struct {
|
|||
}
|
||||
|
||||
type ResponseMsgUser struct {
|
||||
User UserResponse `json:"user"`
|
||||
User `json:"user"`
|
||||
}
|
||||
|
||||
type ResponseMsgScenarios struct {
|
||||
|
|
|
@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue