...
|
...
|
@@ -50,6 +50,27 @@ func (l *MiniUserLoginLogic) MiniUserLogin(req *types.MiniUserLoginRequest) (res |
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
var users []*domain.User
|
|
|
conn := l.svcCtx.DefaultDBConn()
|
|
|
_, users, err = l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().
|
|
|
MustWithKV("phone", loginInfo.Phone).
|
|
|
MustWithKV("auditStatus", []int{domain.UserAuditStatusWait, domain.UserAuditStatusPassed}).
|
|
|
WithFindOnly())
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
if len(users) > 0 {
|
|
|
for _, user := range users {
|
|
|
if user.Enable == domain.UserEnable && user.AuditStatus == domain.UserAuditStatusPassed {
|
|
|
loginInfo.User = user
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
if loginInfo.User == nil {
|
|
|
loginInfo.User = users[0]
|
|
|
}
|
|
|
}
|
|
|
if loginInfo.User == nil {
|
|
|
return nil, xerr.NewErrMsgErr("用户不存在", err)
|
|
|
}
|
...
|
...
|
@@ -102,20 +123,9 @@ func (c WxClientLogin) WechatPhoneLogin(r domain.WechatLoginRequest) (*domain.Lo |
|
|
return response, xerr.NewCodeErrMsg(xerr.ErrWxMiniAuthFailError, nil, fmt.Sprintf("发起授权请求失败1 err : %v , code : %s , authResult : %+v", err, code, authResult))
|
|
|
}
|
|
|
var (
|
|
|
users []*domain.User
|
|
|
phone = authResult.PhoneInfo.PhoneNumber
|
|
|
)
|
|
|
conn := c.l.svcCtx.DefaultDBConn()
|
|
|
_, users, err = c.l.svcCtx.UserRepository.Find(c.l.ctx, conn, domain.NewQueryOptions().
|
|
|
MustWithKV("phone", phone).
|
|
|
MustWithKV("auditStatus", []int{domain.UserAuditStatusPassed}))
|
|
|
if err != nil {
|
|
|
return response, err
|
|
|
}
|
|
|
response.Phone = phone
|
|
|
if len(users) != 0 {
|
|
|
response.User = users[0]
|
|
|
}
|
|
|
return response, nil
|
|
|
}
|
|
|
|
...
|
...
|
@@ -129,7 +139,6 @@ func (c WxClientLogin) PhonePasswordLogin(phone string, password string) (*domai |
|
|
|
|
|
func (c WxClientLogin) PhoneSmsCodeLogin(phone string, code string) (*domain.LoginInfo, error) {
|
|
|
var (
|
|
|
users []*domain.User
|
|
|
err error
|
|
|
skipCheckSmsCode bool = false
|
|
|
)
|
...
|
...
|
@@ -139,19 +148,8 @@ func (c WxClientLogin) PhoneSmsCodeLogin(phone string, code string) (*domain.Log |
|
|
if _, err = c.l.svcCtx.SmsService.CheckSmsCode(c.l.ctx, smslib.RequestCheckSmsCode{Phone: phone, Code: code}); err != nil && !skipCheckSmsCode {
|
|
|
return nil, xerr.NewErrMsgErr(err.Error(), err)
|
|
|
}
|
|
|
conn := c.l.svcCtx.DefaultDBConn()
|
|
|
_, users, err = c.l.svcCtx.UserRepository.Find(c.l.ctx, conn, domain.NewQueryOptions().
|
|
|
MustWithKV("phone", phone).
|
|
|
MustWithKV("auditStatus", []int{domain.UserAuditStatusPassed}).
|
|
|
WithFindOnly())
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
response := &domain.LoginInfo{
|
|
|
Phone: phone,
|
|
|
}
|
|
|
if len(users) != 0 {
|
|
|
response.User = users[0]
|
|
|
}
|
|
|
return response, nil
|
|
|
} |
...
|
...
|
|