fix: 密码重置链路断裂与店铺模板类型不兼容
删除 users-api 的 forgot-password 空壳路由,email-api 的
forgotPasswordLogic 复用 sendVerificationCode 实现。shop 的
UpdateTemplateReq.Sections 从 interface{} 改为 string 以兼容
go-zero 反序列化。ResetPasswordReq.Phone 加 optional tag。
This commit is contained in:
@@ -27,8 +27,9 @@ func NewForgotPasswordLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Fo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *ForgotPasswordLogic) ForgotPassword(req *types.ForgotPasswordReq) (resp *types.EmptyResp, err error) {
|
func (l *ForgotPasswordLogic) ForgotPassword(req *types.ForgotPasswordReq) (resp *types.SendVerificationCodeResp, err error) {
|
||||||
// todo: add your logic here and delete this line
|
return NewSendVerificationCodeLogic(l.ctx, l.svcCtx).SendVerificationCode(&types.SendVerificationCodeReq{
|
||||||
|
Email: req.Email,
|
||||||
return
|
Scene: "reset_password",
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// Code generated by goctl. DO NOT EDIT.
|
// Code generated by goctl. DO NOT EDIT.
|
||||||
// goctl 1.9.2
|
// goctl 1.10.1
|
||||||
|
|
||||||
package handler
|
package handler
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ package shop
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"juwan-backend/app/shop/api/internal/svc"
|
"juwan-backend/app/shop/api/internal/svc"
|
||||||
@@ -48,11 +47,6 @@ func (l *UpdateShopTemplateLogic) UpdateShopTemplate(req *types.UpdateTemplateRe
|
|||||||
return nil, contextj.ERRILLEGALUSER
|
return nil, contextj.ERRILLEGALUSER
|
||||||
}
|
}
|
||||||
|
|
||||||
templateBytes, err := json.Marshal(map[string]any{"sections": req.Sections})
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.New("invalid sections")
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = l.svcCtx.ShopRpc.UpdateShops(l.ctx, &pb.UpdateShopsReq{
|
_, err = l.svcCtx.ShopRpc.UpdateShops(l.ctx, &pb.UpdateShopsReq{
|
||||||
Id: shop.Shops.Id,
|
Id: shop.Shops.Id,
|
||||||
OwnerId: shop.Shops.OwnerId,
|
OwnerId: shop.Shops.OwnerId,
|
||||||
@@ -68,7 +62,7 @@ func (l *UpdateShopTemplateLogic) UpdateShopTemplate(req *types.UpdateTemplateRe
|
|||||||
AllowIndependentOrders: shop.Shops.AllowIndependentOrders,
|
AllowIndependentOrders: shop.Shops.AllowIndependentOrders,
|
||||||
DispatchMode: shop.Shops.DispatchMode,
|
DispatchMode: shop.Shops.DispatchMode,
|
||||||
Announcements: shop.Shops.Announcements,
|
Announcements: shop.Shops.Announcements,
|
||||||
TemplateConfig: string(templateBytes),
|
TemplateConfig: req.Sections,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// Code generated by goctl. DO NOT EDIT.
|
// Code generated by goctl. DO NOT EDIT.
|
||||||
// goctl 1.9.2
|
// goctl 1.10.1
|
||||||
|
|
||||||
package types
|
package types
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ type UpdateShopReq struct {
|
|||||||
|
|
||||||
type UpdateTemplateReq struct {
|
type UpdateTemplateReq struct {
|
||||||
Id int64 `path:"id"`
|
Id int64 `path:"id"`
|
||||||
Sections interface{} `json:"sections"`
|
Sections string `json:"sections"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserIdReq struct {
|
type UserIdReq struct {
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
// Code scaffolded by goctl. Safe to edit.
|
|
||||||
// goctl 1.9.2
|
|
||||||
|
|
||||||
package auth
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/rest/httpx"
|
|
||||||
"juwan-backend/app/users/api/internal/logic/auth"
|
|
||||||
"juwan-backend/app/users/api/internal/svc"
|
|
||||||
"juwan-backend/app/users/api/internal/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
// 忘记密码-发送验证码
|
|
||||||
func ForgotPasswordHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
var req types.ForgotPasswordReq
|
|
||||||
if err := httpx.Parse(r, &req); err != nil {
|
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
l := auth.NewForgotPasswordLogic(r.Context(), svcCtx)
|
|
||||||
resp, err := l.ForgotPassword(&req)
|
|
||||||
if err != nil {
|
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
|
||||||
} else {
|
|
||||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
// Code generated by goctl. DO NOT EDIT.
|
// Code generated by goctl. DO NOT EDIT.
|
||||||
// goctl 1.9.2
|
// goctl 1.10.1
|
||||||
|
|
||||||
package handler
|
package handler
|
||||||
|
|
||||||
@@ -18,12 +18,6 @@ import (
|
|||||||
func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||||
server.AddRoutes(
|
server.AddRoutes(
|
||||||
[]rest.Route{
|
[]rest.Route{
|
||||||
{
|
|
||||||
// 忘记密码-发送验证码
|
|
||||||
Method: http.MethodPost,
|
|
||||||
Path: "/forgot-password",
|
|
||||||
Handler: auth.ForgotPasswordHandler(serverCtx),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
// 用户登录
|
// 用户登录
|
||||||
Method: http.MethodPost,
|
Method: http.MethodPost,
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
// Code scaffolded by goctl. Safe to edit.
|
|
||||||
// goctl 1.9.2
|
|
||||||
|
|
||||||
package auth
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"juwan-backend/app/users/api/internal/svc"
|
|
||||||
"juwan-backend/app/users/api/internal/types"
|
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ForgotPasswordLogic struct {
|
|
||||||
logx.Logger
|
|
||||||
ctx context.Context
|
|
||||||
svcCtx *svc.ServiceContext
|
|
||||||
}
|
|
||||||
|
|
||||||
// 忘记密码-发送验证码
|
|
||||||
func NewForgotPasswordLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ForgotPasswordLogic {
|
|
||||||
return &ForgotPasswordLogic{
|
|
||||||
Logger: logx.WithContext(ctx),
|
|
||||||
ctx: ctx,
|
|
||||||
svcCtx: svcCtx,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *ForgotPasswordLogic) ForgotPassword(req *types.ForgotPasswordReq) (resp *types.EmptyResp, err error) {
|
|
||||||
// todo: add your logic here and delete this line
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
// Code generated by goctl. DO NOT EDIT.
|
// Code generated by goctl. DO NOT EDIT.
|
||||||
// goctl 1.9.2
|
// goctl 1.10.1
|
||||||
|
|
||||||
package types
|
package types
|
||||||
|
|
||||||
@@ -15,11 +15,6 @@ type FollowUserReq struct {
|
|||||||
Id int64 `path:"id"`
|
Id int64 `path:"id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ForgotPasswordReq struct {
|
|
||||||
Phone string `json:"phone,omitempty"`
|
|
||||||
Email string `json:"email,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetMyVerificationsResp struct {
|
type GetMyVerificationsResp struct {
|
||||||
List []VerificationItem `json:"list"`
|
List []VerificationItem `json:"list"`
|
||||||
}
|
}
|
||||||
@@ -57,8 +52,8 @@ type LogoutReq struct {
|
|||||||
type MaterialJson struct {
|
type MaterialJson struct {
|
||||||
IdCardFront string `json:"idCardFront"` // 身份证正面照片URL
|
IdCardFront string `json:"idCardFront"` // 身份证正面照片URL
|
||||||
IdCardBack string `json:"idCardBack"` // 身份证反面照片URL
|
IdCardBack string `json:"idCardBack"` // 身份证反面照片URL
|
||||||
GameScreenshots []string `json:"gameScreenshots"` // 游戏截图URL列表
|
GameScreenshots []*string `json:"gameScreenshots,optional"` // 游戏截图URL列表
|
||||||
VoiceDemo string `json:"voiceDemo"` // 语音认证示例URL
|
VoiceDemo *string `json:"voiceDemo,optional"` // 语音认证示例URL
|
||||||
}
|
}
|
||||||
|
|
||||||
type RegisterReq struct {
|
type RegisterReq struct {
|
||||||
@@ -79,7 +74,7 @@ type RejectVerificationReq struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ResetPasswordReq struct {
|
type ResetPasswordReq struct {
|
||||||
Phone string `json:"phone,omitempty"`
|
Phone string `json:"phone,optional"`
|
||||||
Email string `json:"email,omitempty"`
|
Email string `json:"email,omitempty"`
|
||||||
Vcode string `json:"vcode"`
|
Vcode string `json:"vcode"`
|
||||||
NewPassword string `json:"newPassword"`
|
NewPassword string `json:"newPassword"`
|
||||||
|
|||||||
+1
-1
@@ -39,7 +39,7 @@ type (
|
|||||||
}
|
}
|
||||||
UpdateTemplateReq {
|
UpdateTemplateReq {
|
||||||
Id int64 `path:"id"`
|
Id int64 `path:"id"`
|
||||||
Sections interface{} `json:"sections"`
|
Sections string `json:"sections"`
|
||||||
}
|
}
|
||||||
AnnouncementReq {
|
AnnouncementReq {
|
||||||
Id int64 `path:"id"`
|
Id int64 `path:"id"`
|
||||||
|
|||||||
+1
-9
@@ -107,12 +107,8 @@ type (
|
|||||||
User User `json:"user"`
|
User User `json:"user"`
|
||||||
}
|
}
|
||||||
LogoutReq {}
|
LogoutReq {}
|
||||||
ForgotPasswordReq {
|
|
||||||
Phone string `json:"phone,omitempty"`
|
|
||||||
Email string `json:"email,omitempty"`
|
|
||||||
}
|
|
||||||
ResetPasswordReq {
|
ResetPasswordReq {
|
||||||
Phone string `json:"phone,omitempty"`
|
Phone string `json:"phone,optional"`
|
||||||
Email string `json:"email,omitempty"`
|
Email string `json:"email,omitempty"`
|
||||||
Vcode string `json:"vcode"`
|
Vcode string `json:"vcode"`
|
||||||
NewPassword string `json:"newPassword"`
|
NewPassword string `json:"newPassword"`
|
||||||
@@ -172,10 +168,6 @@ service user-api {
|
|||||||
@handler Login
|
@handler Login
|
||||||
post /login (LoginReq) returns (LoginResp)
|
post /login (LoginReq) returns (LoginResp)
|
||||||
|
|
||||||
@doc "忘记密码-发送验证码"
|
|
||||||
@handler ForgotPassword
|
|
||||||
post /forgot-password (ForgotPasswordReq) returns (EmptyResp)
|
|
||||||
|
|
||||||
@doc "重置密码"
|
@doc "重置密码"
|
||||||
@handler ResetPassword
|
@handler ResetPassword
|
||||||
post /reset-password (ResetPasswordReq) returns (EmptyResp)
|
post /reset-password (ResetPasswordReq) returns (EmptyResp)
|
||||||
|
|||||||
Reference in New Issue
Block a user