调整微信登录二维码请求限制,修改商户注册接口
This commit is contained in:
@ -19,24 +19,24 @@ import (
|
||||
|
||||
func (c *ControllerV1) WeChatLogin(ctx context.Context, req *v1.WeChatLoginReq) (res *v1.WeChatLoginRes, err error) {
|
||||
glog.Infof(ctx, "收到微信登录请求,SceneId: %s", req.SceneId)
|
||||
loginLimitKey := fmt.Sprintf(consts.WeChatLoginLimit, req.SceneId)
|
||||
|
||||
// 检查登录限制
|
||||
va, err := g.Redis().Get(ctx, loginLimitKey)
|
||||
if err != nil {
|
||||
glog.Errorf(ctx, "Redis 获取登录限制失败: %v", err)
|
||||
return nil, ecode.Fail.Sub("获取登录限制失败")
|
||||
}
|
||||
|
||||
if !va.IsEmpty() {
|
||||
glog.Warningf(ctx, "SceneId %s 登录请求过于频繁", req.SceneId)
|
||||
return nil, ecode.InvalidOperation.Sub("请勿重复请求登录二维码")
|
||||
}
|
||||
|
||||
if err = g.Redis().SetEX(ctx, loginLimitKey, 1, 60); err != nil {
|
||||
glog.Errorf(ctx, "Redis 设置登录限制失败: %v", err)
|
||||
return nil, ecode.Fail.Sub("登录频率限制设置失败")
|
||||
}
|
||||
//loginLimitKey := fmt.Sprintf(consts.WeChatLoginLimit, req.SceneId)
|
||||
//
|
||||
//// 检查登录限制
|
||||
//va, err := g.Redis().Get(ctx, loginLimitKey)
|
||||
//if err != nil {
|
||||
// glog.Errorf(ctx, "Redis 获取登录限制失败: %v", err)
|
||||
// return nil, ecode.Fail.Sub("获取登录限制失败")
|
||||
//}
|
||||
//
|
||||
//if !va.IsEmpty() {
|
||||
// glog.Warningf(ctx, "SceneId %s 登录请求过于频繁", req.SceneId)
|
||||
// return nil, ecode.InvalidOperation.Sub("请勿重复请求登录二维码")
|
||||
//}
|
||||
//
|
||||
//if err = g.Redis().SetEX(ctx, loginLimitKey, 1, 60); err != nil {
|
||||
// glog.Errorf(ctx, "Redis 设置登录限制失败: %v", err)
|
||||
// return nil, ecode.Fail.Sub("登录频率限制设置失败")
|
||||
//}
|
||||
|
||||
client := wechat.GetWeChatClient()
|
||||
ticket, err := client.GetTicket(fmt.Sprintf("%s", req.SceneId))
|
||||
|
||||
Reference in New Issue
Block a user