From 37366dc2e1d72e51c324f6871a82ade317f2d104 Mon Sep 17 00:00:00 2001 From: Zeng1998 Date: Mon, 6 Mar 2023 19:13:09 +0800 Subject: [PATCH] fix: patch user with nil password (#1290) --- api/user.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/user.go b/api/user.go index cc2c2ff6..fcf4f862 100644 --- a/api/user.go +++ b/api/user.go @@ -113,10 +113,10 @@ func (patch UserPatch) Validate() error { if patch.Username != nil && len(*patch.Username) > 32 { return fmt.Errorf("username is too long, maximum length is 32") } - if len(*patch.Password) < 3 { + if patch.Password != nil && len(*patch.Password) < 3 { return fmt.Errorf("password is too short, minimum length is 6") } - if len(*patch.Password) > 512 { + if patch.Password != nil && len(*patch.Password) > 512 { return fmt.Errorf("password is too long, maximum length is 512") } if patch.Nickname != nil && len(*patch.Nickname) > 64 {