正在显示
1 个修改的文件
包含
21 行增加
和
23 行删除
@@ -50,6 +50,27 @@ func (l *MiniUserLoginLogic) MiniUserLogin(req *types.MiniUserLoginRequest) (res | @@ -50,6 +50,27 @@ func (l *MiniUserLoginLogic) MiniUserLogin(req *types.MiniUserLoginRequest) (res | ||
50 | if err != nil { | 50 | if err != nil { |
51 | return | 51 | return |
52 | } | 52 | } |
53 | + | ||
54 | + var users []*domain.User | ||
55 | + conn := l.svcCtx.DefaultDBConn() | ||
56 | + _, users, err = l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions(). | ||
57 | + MustWithKV("phone", loginInfo.Phone). | ||
58 | + MustWithKV("auditStatus", []int{domain.UserAuditStatusWait, domain.UserAuditStatusPassed}). | ||
59 | + WithFindOnly()) | ||
60 | + if err != nil { | ||
61 | + return nil, err | ||
62 | + } | ||
63 | + if len(users) > 0 { | ||
64 | + for _, user := range users { | ||
65 | + if user.Enable == domain.UserEnable && user.AuditStatus == domain.UserAuditStatusPassed { | ||
66 | + loginInfo.User = user | ||
67 | + break | ||
68 | + } | ||
69 | + } | ||
70 | + if loginInfo.User == nil { | ||
71 | + loginInfo.User = users[0] | ||
72 | + } | ||
73 | + } | ||
53 | if loginInfo.User == nil { | 74 | if loginInfo.User == nil { |
54 | return nil, xerr.NewErrMsgErr("用户不存在", err) | 75 | return nil, xerr.NewErrMsgErr("用户不存在", err) |
55 | } | 76 | } |
@@ -102,20 +123,9 @@ func (c WxClientLogin) WechatPhoneLogin(r domain.WechatLoginRequest) (*domain.Lo | @@ -102,20 +123,9 @@ func (c WxClientLogin) WechatPhoneLogin(r domain.WechatLoginRequest) (*domain.Lo | ||
102 | return response, xerr.NewCodeErrMsg(xerr.ErrWxMiniAuthFailError, nil, fmt.Sprintf("发起授权请求失败1 err : %v , code : %s , authResult : %+v", err, code, authResult)) | 123 | return response, xerr.NewCodeErrMsg(xerr.ErrWxMiniAuthFailError, nil, fmt.Sprintf("发起授权请求失败1 err : %v , code : %s , authResult : %+v", err, code, authResult)) |
103 | } | 124 | } |
104 | var ( | 125 | var ( |
105 | - users []*domain.User | ||
106 | phone = authResult.PhoneInfo.PhoneNumber | 126 | phone = authResult.PhoneInfo.PhoneNumber |
107 | ) | 127 | ) |
108 | - conn := c.l.svcCtx.DefaultDBConn() | ||
109 | - _, users, err = c.l.svcCtx.UserRepository.Find(c.l.ctx, conn, domain.NewQueryOptions(). | ||
110 | - MustWithKV("phone", phone). | ||
111 | - MustWithKV("auditStatus", []int{domain.UserAuditStatusPassed})) | ||
112 | - if err != nil { | ||
113 | - return response, err | ||
114 | - } | ||
115 | response.Phone = phone | 128 | response.Phone = phone |
116 | - if len(users) != 0 { | ||
117 | - response.User = users[0] | ||
118 | - } | ||
119 | return response, nil | 129 | return response, nil |
120 | } | 130 | } |
121 | 131 | ||
@@ -129,7 +139,6 @@ func (c WxClientLogin) PhonePasswordLogin(phone string, password string) (*domai | @@ -129,7 +139,6 @@ func (c WxClientLogin) PhonePasswordLogin(phone string, password string) (*domai | ||
129 | 139 | ||
130 | func (c WxClientLogin) PhoneSmsCodeLogin(phone string, code string) (*domain.LoginInfo, error) { | 140 | func (c WxClientLogin) PhoneSmsCodeLogin(phone string, code string) (*domain.LoginInfo, error) { |
131 | var ( | 141 | var ( |
132 | - users []*domain.User | ||
133 | err error | 142 | err error |
134 | skipCheckSmsCode bool = false | 143 | skipCheckSmsCode bool = false |
135 | ) | 144 | ) |
@@ -139,19 +148,8 @@ func (c WxClientLogin) PhoneSmsCodeLogin(phone string, code string) (*domain.Log | @@ -139,19 +148,8 @@ func (c WxClientLogin) PhoneSmsCodeLogin(phone string, code string) (*domain.Log | ||
139 | if _, err = c.l.svcCtx.SmsService.CheckSmsCode(c.l.ctx, smslib.RequestCheckSmsCode{Phone: phone, Code: code}); err != nil && !skipCheckSmsCode { | 148 | if _, err = c.l.svcCtx.SmsService.CheckSmsCode(c.l.ctx, smslib.RequestCheckSmsCode{Phone: phone, Code: code}); err != nil && !skipCheckSmsCode { |
140 | return nil, xerr.NewErrMsgErr(err.Error(), err) | 149 | return nil, xerr.NewErrMsgErr(err.Error(), err) |
141 | } | 150 | } |
142 | - conn := c.l.svcCtx.DefaultDBConn() | ||
143 | - _, users, err = c.l.svcCtx.UserRepository.Find(c.l.ctx, conn, domain.NewQueryOptions(). | ||
144 | - MustWithKV("phone", phone). | ||
145 | - MustWithKV("auditStatus", []int{domain.UserAuditStatusPassed}). | ||
146 | - WithFindOnly()) | ||
147 | - if err != nil { | ||
148 | - return nil, err | ||
149 | - } | ||
150 | response := &domain.LoginInfo{ | 151 | response := &domain.LoginInfo{ |
151 | Phone: phone, | 152 | Phone: phone, |
152 | } | 153 | } |
153 | - if len(users) != 0 { | ||
154 | - response.User = users[0] | ||
155 | - } | ||
156 | return response, nil | 154 | return response, nil |
157 | } | 155 | } |
-
请 注册 或 登录 后发表评论