...
|
...
|
@@ -77,6 +77,7 @@ func (svr AuthService) AuthLoginPwd(loginCommand *command.LoginPwdCommand) (inte |
|
|
Phone: loginCommand.Username,
|
|
|
Password: loginCommand.Password,
|
|
|
SessionMode: loginCommand.SessionMode,
|
|
|
DeviceType: loginCommand.DeviceType,
|
|
|
}
|
|
|
if len(loginCommand.CaptchaChallenge) > 0 {
|
|
|
geetest := geetest.NewGeetestLib(captchaID, privateKey, 2*time.Second)
|
...
|
...
|
@@ -98,6 +99,7 @@ func (svr AuthService) AuthLoginSms(loginCommand *command.LoginSmsCommand) (inte |
|
|
Phone: loginCommand.Phone,
|
|
|
Captcha: loginCommand.Code,
|
|
|
SessionMode: loginCommand.SessionMode,
|
|
|
DeviceType: loginCommand.DeviceType,
|
|
|
}
|
|
|
return svr.AuthLogin(login)
|
|
|
}
|
...
|
...
|
@@ -105,14 +107,23 @@ func (svr AuthService) AuthLoginSms(loginCommand *command.LoginSmsCommand) (inte |
|
|
//AuthLoginQrcode 扫码登录
|
|
|
func (svr AuthService) AuthLoginQrcode(queryParam *query.QrcodeLoginStatusQuery) (interface{}, error) {
|
|
|
qrmsg := domain.QrcodeMessage{}
|
|
|
failLoginData := map[string]interface{}{
|
|
|
"isLogin": false,
|
|
|
"access": struct{}{},
|
|
|
}
|
|
|
err := qrmsg.ParseToken(queryParam.Key)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
log.Logger.Error(err.Error())
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "二维码已失效")
|
|
|
}
|
|
|
qrCache := cache.LoginQrcodeCache{}
|
|
|
qrmsgCache, err := qrCache.Get(qrmsg.Id)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
log.Logger.Error(err.Error())
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "二维码已失效")
|
|
|
}
|
|
|
if !qrmsgCache.IsLogin {
|
|
|
return failLoginData, nil
|
|
|
}
|
|
|
loginToken := domain.LoginToken{
|
|
|
UserId: qrmsgCache.UserId,
|
...
|
...
|
@@ -126,6 +137,7 @@ func (svr AuthService) AuthLoginQrcode(queryParam *query.QrcodeLoginStatusQuery) |
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
qrCache.Remove(qrmsgCache.Id)
|
|
|
_ = accessToken
|
|
|
result, err := svr.getToken(loginToken)
|
|
|
data := map[string]interface{}{
|
...
|
...
|
@@ -135,6 +147,28 @@ func (svr AuthService) AuthLoginQrcode(queryParam *query.QrcodeLoginStatusQuery) |
|
|
return data, nil
|
|
|
}
|
|
|
|
|
|
//AuthLoginQrcodeBind 扫码登录-绑定
|
|
|
func (svr AuthService) AuthLoginQrcodeBinding(bindingCmd *command.QrcodeBindingCommand) (interface{}, error) {
|
|
|
qrmsg := domain.QrcodeMessage{}
|
|
|
err := qrmsg.ParseToken(bindingCmd.Key)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "二维码已失效,请重试")
|
|
|
}
|
|
|
qrCache := cache.LoginQrcodeCache{}
|
|
|
qrmsgCache, err := qrCache.Get(qrmsg.Id)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := qrmsgCache.BindUser(bindingCmd.Operator); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := qrCache.Save(*qrmsgCache); err != nil {
|
|
|
log.Logger.Error(err.Error())
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "登录失败,请重试")
|
|
|
}
|
|
|
return struct{}{}, nil
|
|
|
}
|
|
|
|
|
|
//SendSmsCaptcha 发送验证码短信
|
|
|
func (svr AuthService) SendSmsCaptcha(smsCodeCommand *command.SendSmsCodeCommand) error {
|
|
|
smsServeGateway := sms_serve.NewHttplibHttplibSmsServe()
|
...
|
...
|
@@ -199,6 +233,7 @@ func (svr AuthService) GetAuthAccessToken(accessTokenCommand *command.AccessToke |
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
loginToken.Platform = accessTokenCommand.LoginPlatform
|
|
|
loginToken.SessionMode = accessTokenCommand.SessionMode
|
|
|
result, err := svr.getToken(*loginToken)
|
|
|
return result["token"], err
|
|
|
}
|
...
|
...
|
|