From 16a3cc75183e08b04779b44f719a7aa032791b88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AC=A7=E9=98=B3=E5=A4=A7=E5=93=A5?= Date: Thu, 8 Aug 2024 23:46:46 +0800 Subject: [PATCH] fix: chat not set sms and email, reset password use supercode. (#566) --- internal/rpc/chat/password.go | 3 +++ pkg/common/db/database/chat.go | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/rpc/chat/password.go b/internal/rpc/chat/password.go index 6235a2df..09db40a6 100644 --- a/internal/rpc/chat/password.go +++ b/internal/rpc/chat/password.go @@ -46,6 +46,9 @@ func (o *chatSvr) ResetPassword(ctx context.Context, req *chat.ResetPasswordReq) return nil, err } err = o.Database.UpdatePasswordAndDeleteVerifyCode(ctx, attribute.UserID, req.Password, verifyCodeID) + if err != nil { + return nil, err + } } else { attribute, err := o.Database.GetAttributeByEmail(ctx, req.Email) if err != nil { diff --git a/pkg/common/db/database/chat.go b/pkg/common/db/database/chat.go index e618845a..9fc5b028 100644 --- a/pkg/common/db/database/chat.go +++ b/pkg/common/db/database/chat.go @@ -243,8 +243,10 @@ func (o *ChatDatabase) UpdatePasswordAndDeleteVerifyCode(ctx context.Context, us if err := o.account.UpdatePassword(ctx, userID, password); err != nil { return err } - if err := o.verifyCode.Delete(ctx, codeID); err != nil { - return err + if len(codeID) > 0 { + if err := o.verifyCode.Delete(ctx, codeID); err != nil { + return err + } } return nil })