fix some bugs with userID caused by code restructuring in prev commits

This commit is contained in:
Sonja Happ 2019-09-09 12:42:27 +02:00
parent 99f71d80c7
commit 7b8fc67512

View file

@ -268,7 +268,7 @@ func updateUser(c *gin.Context) {
// Get the user's (to be updated) ID from the context // Get the user's (to be updated) ID from the context
var oldUser User var oldUser User
toBeUpdatedID, err := strconv.Atoi("userID") toBeUpdatedID, err := strconv.Atoi(c.Param("userID"))
if err != nil { if err != nil {
c.JSON(http.StatusNotFound, gin.H{ c.JSON(http.StatusNotFound, gin.H{
"success": false, "success": false,
@ -313,7 +313,7 @@ func updateUser(c *gin.Context) {
return return
} }
if toBeUpdatedID != callerID && callerRole != "Admin" { if uint(toBeUpdatedID) != callerID && callerRole != "Admin" {
c.JSON(http.StatusForbidden, gin.H{ c.JSON(http.StatusForbidden, gin.H{
"success": false, "success": false,
"message": "Invalid authorization", "message": "Invalid authorization",
@ -394,7 +394,7 @@ func getUser(c *gin.Context) {
return return
} }
id, err := strconv.Atoi("userID") id, err := strconv.Atoi(c.Param("userID"))
if err != nil { if err != nil {
c.JSON(http.StatusNotFound, gin.H{ c.JSON(http.StatusNotFound, gin.H{
"success": false, "success": false,
@ -449,7 +449,7 @@ func deleteUser(c *gin.Context) {
} }
var user User var user User
id, err := strconv.Atoi("userID") id, err := strconv.Atoi(c.Param("userID"))
if err != nil { if err != nil {
c.JSON(http.StatusNotFound, gin.H{ c.JSON(http.StatusNotFound, gin.H{
"success": false, "success": false,