fix: make validator happy by set a temp password

This commit is contained in:
JustSong
2022-11-11 20:11:51 +08:00
parent d42b4511cf
commit f484e593f6
+6
View File
@@ -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{