fix: make validator happy by set a temp password
This commit is contained in:
@@ -295,6 +295,9 @@ func UpdateUser(c *gin.Context) {
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if updatedUser.Password == "" {
|
||||||
|
updatedUser.Password = "$I_LOVE_U" // make Validator happy :)
|
||||||
|
}
|
||||||
if err := common.Validate.Struct(&updatedUser); err != nil {
|
if err := common.Validate.Struct(&updatedUser); err != nil {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"success": false,
|
"success": false,
|
||||||
@@ -325,6 +328,9 @@ func UpdateUser(c *gin.Context) {
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if updatedUser.Password == "$I_LOVE_U" {
|
||||||
|
updatedUser.Password = "" // rollback to what it should be
|
||||||
|
}
|
||||||
updatePassword := updatedUser.Password != ""
|
updatePassword := updatedUser.Password != ""
|
||||||
if err := updatedUser.Update(updatePassword); err != nil {
|
if err := updatedUser.Update(updatePassword); err != nil {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
|
|||||||
Reference in New Issue
Block a user