...
|
...
|
@@ -53,13 +53,7 @@ func (l *MiniUserLoginLogic) MiniUserLogin(req *types.MiniUserLoginRequest) (res |
|
|
if loginInfo.User == nil {
|
|
|
return nil, xerr.NewErrMsgErr("用户不存在", err)
|
|
|
}
|
|
|
var userJwtToken = tool.UserToken{}
|
|
|
if loginInfo.User != nil {
|
|
|
userJwtToken.UserId = loginInfo.User.Id
|
|
|
userJwtToken.CompanyId = loginInfo.User.CompanyId
|
|
|
userJwtToken.ClientType = "mini"
|
|
|
}
|
|
|
token, err = userJwtToken.GenerateToken(l.svcCtx.Config.MiniAuth.AccessSecret, l.svcCtx.Config.MiniAuth.AccessExpire)
|
|
|
token, err = generateToken(l.svcCtx, loginInfo.User)
|
|
|
if err != nil {
|
|
|
return nil, xerr.NewErrMsgErr("登录失败", err)
|
|
|
}
|
...
|
...
|
@@ -74,6 +68,20 @@ func (l *MiniUserLoginLogic) MiniUserLogin(req *types.MiniUserLoginRequest) (res |
|
|
return
|
|
|
}
|
|
|
|
|
|
func generateToken(svcCtx *svc.ServiceContext, user *domain.User) (token string, err error) {
|
|
|
var userJwtToken = tool.UserToken{}
|
|
|
if user != nil {
|
|
|
userJwtToken.UserId = user.Id
|
|
|
userJwtToken.CompanyId = user.CompanyId
|
|
|
userJwtToken.ClientType = "mini"
|
|
|
}
|
|
|
token, err = userJwtToken.GenerateToken(svcCtx.Config.MiniAuth.AccessSecret, svcCtx.Config.MiniAuth.AccessExpire)
|
|
|
if err != nil {
|
|
|
return "", xerr.NewErrMsgErr("登录失败", err)
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
type WxClientLogin struct {
|
|
|
l *MiniUserLoginLogic
|
|
|
}
|
...
|
...
|
@@ -119,10 +127,14 @@ 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
|
|
|
users []*domain.User
|
|
|
err error
|
|
|
skipCheckSmsCode bool = false
|
|
|
)
|
|
|
if _, err = c.l.svcCtx.SmsService.CheckSmsCode(c.l.ctx, smslib.RequestCheckSmsCode{Phone: phone, Code: code}); err != nil {
|
|
|
if c.l.svcCtx.Config.DebugSmsCode != "" && c.l.svcCtx.Config.DebugSmsCode == code {
|
|
|
skipCheckSmsCode = true
|
|
|
}
|
|
|
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()
|
...
|
...
|
|