From f484e593f6d85bfbd923a899d4e0275e8f0362e1 Mon Sep 17 00:00:00 2001 From: JustSong Date: Fri, 11 Nov 2022 20:11:51 +0800 Subject: [PATCH] fix: make validator happy by set a temp password --- controller/user.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/controller/user.go b/controller/user.go index b68a4c1..8947225 100644 --- a/controller/user.go +++ b/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{