From d596d41e1a735f5110547c2bf4315b380029caaa Mon Sep 17 00:00:00 2001 From: zetaloop Date: Thu, 23 Apr 2026 14:58:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=BB=9F=E4=B8=80=E9=87=8D=E7=BD=AE?= =?UTF-8?q?=E5=AF=86=E7=A0=81=E9=AA=8C=E8=AF=81=E7=A0=81=E7=9A=84=20scene?= =?UTF-8?q?=20=E5=B8=B8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/email/api/internal/logic/email/forgotPasswordLogic.go | 3 ++- app/users/rpc/internal/logic/resetPasswordLogic.go | 3 ++- common/redisx/keys.go | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/email/api/internal/logic/email/forgotPasswordLogic.go b/app/email/api/internal/logic/email/forgotPasswordLogic.go index e8e46e2..1d13b1a 100644 --- a/app/email/api/internal/logic/email/forgotPasswordLogic.go +++ b/app/email/api/internal/logic/email/forgotPasswordLogic.go @@ -8,6 +8,7 @@ import ( "juwan-backend/app/email/api/internal/svc" "juwan-backend/app/email/api/internal/types" + "juwan-backend/common/redisx" "github.com/zeromicro/go-zero/core/logx" ) @@ -30,6 +31,6 @@ func NewForgotPasswordLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Fo func (l *ForgotPasswordLogic) ForgotPassword(req *types.ForgotPasswordReq) (resp *types.SendVerificationCodeResp, err error) { return NewSendVerificationCodeLogic(l.ctx, l.svcCtx).SendVerificationCode(&types.SendVerificationCodeReq{ Email: req.Email, - Scene: "reset_password", + Scene: redisx.SCENE_RESET_PWD, }) } diff --git a/app/users/rpc/internal/logic/resetPasswordLogic.go b/app/users/rpc/internal/logic/resetPasswordLogic.go index e9d9180..a1e0982 100644 --- a/app/users/rpc/internal/logic/resetPasswordLogic.go +++ b/app/users/rpc/internal/logic/resetPasswordLogic.go @@ -29,7 +29,7 @@ func NewResetPasswordLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Res func (l *ResetPasswordLogic) ResetPassword(in *pb.ResetPasswordReq) (*pb.ResetPasswordResp, error) { // todo: add your logic here and delete this line - redisKey := fmt.Sprintf(redisx.VCODE_KEY_PREFIX, in.RequestId, redisx.SCENE_REG, in.Email) + redisKey := fmt.Sprintf(redisx.VCODE_KEY_PREFIX, in.RequestId, redisx.SCENE_RESET_PWD, in.Email) vcode, err := l.svcCtx.RedisCluster.Get(l.ctx, redisKey).Result() if err != nil { logx.Errorf("get reset password vcode from redis failed, err:%v.", err) @@ -38,6 +38,7 @@ func (l *ResetPasswordLogic) ResetPassword(in *pb.ResetPasswordReq) (*pb.ResetPa if vcode != in.Vcode { return nil, errors.New(fmt.Sprintf("user %v reset password failed, invalid vcode.", in.Email)) } + // in.NewPassword is already bcrypt-hashed by the API layer err = l.svcCtx.UsersModelRW.Users.Update().Where(users.EmailEQ(in.Email)). SetPasswordHash(in.NewPassword). Exec(l.ctx) diff --git a/common/redisx/keys.go b/common/redisx/keys.go index 04b7ccb..204740d 100644 --- a/common/redisx/keys.go +++ b/common/redisx/keys.go @@ -3,7 +3,7 @@ package redisx const ( VCODE_KEY_PREFIX = "vcode:%s:%s:%s" // vocde::: SCENE_LOGIN = "login" - SCENE_RESET_PWD = "reset_pwd" + SCENE_RESET_PWD = "reset_password" SCENE_BIND = "bind" SCENE_REG = "register" )