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 })