mirror of
https://git.rwth-aachen.de/acs/public/villas/web-backend-go/
synced 2025-03-30 00:00:12 +01:00
Fix bug of User marshaling:
Instead of using the json.Marshal() we can user `gin.H` type of the response that will be passed through an XMLMarshaler. In that case we don't even need the responses structs!!
This commit is contained in:
parent
28d81e52c2
commit
42f473cde0
1 changed files with 2 additions and 23 deletions
|
@ -1,7 +1,6 @@
|
||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
@ -126,20 +125,11 @@ func authenticate(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
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{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"success": true,
|
"success": true,
|
||||||
"message": "Authenticated",
|
"message": "Authenticated",
|
||||||
"token": tokenString,
|
"token": tokenString,
|
||||||
"user": response,
|
"user": user.User,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,18 +377,7 @@ func getUser(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
response, err := json.Marshal(common.ResponseMsgUser{user.User})
|
c.JSON(http.StatusOK, gin.H{"user": 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": response,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteUser godoc
|
// DeleteUser godoc
|
||||||
|
|
Loading…
Add table
Reference in a new issue