From 7b8fc67512930e7aeb6c1a03ca14f624d0d2284a Mon Sep 17 00:00:00 2001 From: Sonja Happ Date: Mon, 9 Sep 2019 12:42:27 +0200 Subject: [PATCH] fix some bugs with userID caused by code restructuring in prev commits --- routes/user/user_endpoints.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/routes/user/user_endpoints.go b/routes/user/user_endpoints.go index bb9f472..66738c8 100644 --- a/routes/user/user_endpoints.go +++ b/routes/user/user_endpoints.go @@ -268,7 +268,7 @@ func updateUser(c *gin.Context) { // Get the user's (to be updated) ID from the context var oldUser User - toBeUpdatedID, err := strconv.Atoi("userID") + toBeUpdatedID, err := strconv.Atoi(c.Param("userID")) if err != nil { c.JSON(http.StatusNotFound, gin.H{ "success": false, @@ -313,7 +313,7 @@ func updateUser(c *gin.Context) { return } - if toBeUpdatedID != callerID && callerRole != "Admin" { + if uint(toBeUpdatedID) != callerID && callerRole != "Admin" { c.JSON(http.StatusForbidden, gin.H{ "success": false, "message": "Invalid authorization", @@ -394,7 +394,7 @@ func getUser(c *gin.Context) { return } - id, err := strconv.Atoi("userID") + id, err := strconv.Atoi(c.Param("userID")) if err != nil { c.JSON(http.StatusNotFound, gin.H{ "success": false, @@ -449,7 +449,7 @@ func deleteUser(c *gin.Context) { } var user User - id, err := strconv.Atoi("userID") + id, err := strconv.Atoi(c.Param("userID")) if err != nil { c.JSON(http.StatusNotFound, gin.H{ "success": false,