1
0
Эх сурвалжийг харах

fix: make validator happy by set a temp password

JustSong 2 жил өмнө
parent
commit
f484e593f6
1 өөрчлөгдсөн 6 нэмэгдсэн , 0 устгасан
  1. 6 0
      controller/user.go

+ 6 - 0
controller/user.go

@@ -295,6 +295,9 @@ func UpdateUser(c *gin.Context) {
 		})
 		return
 	}
+	if updatedUser.Password == "" {
+		updatedUser.Password = "$I_LOVE_U" // make Validator happy :)
+	}
 	if err := common.Validate.Struct(&updatedUser); err != nil {
 		c.JSON(http.StatusOK, gin.H{
 			"success": false,
@@ -325,6 +328,9 @@ func UpdateUser(c *gin.Context) {
 		})
 		return
 	}
+	if updatedUser.Password == "$I_LOVE_U" {
+		updatedUser.Password = "" // rollback to what it should be
+	}
 	updatePassword := updatedUser.Password != ""
 	if err := updatedUser.Update(updatePassword); err != nil {
 		c.JSON(http.StatusOK, gin.H{