...
|
...
|
@@ -107,45 +107,36 @@ 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)
|
|
|
cache := cache.LoginQrcodeCache{}
|
|
|
qrcodeMessage, err := cache.Get(queryParam.Key)
|
|
|
if err != nil {
|
|
|
log.Logger.Error(err.Error())
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "二维码已失效")
|
|
|
}
|
|
|
qrCache := cache.LoginQrcodeCache{}
|
|
|
qrmsgCache, err := qrCache.Get(qrmsg.Id)
|
|
|
if err != nil {
|
|
|
log.Logger.Error(err.Error())
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "二维码已失效")
|
|
|
}
|
|
|
if !qrmsgCache.IsLogin {
|
|
|
if !qrcodeMessage.IsLogin {
|
|
|
return failLoginData, nil
|
|
|
}
|
|
|
|
|
|
loginToken := domain.LoginToken{
|
|
|
UserId: qrmsgCache.UserId,
|
|
|
UserBaseId: qrmsgCache.UserBaseId,
|
|
|
Account: qrmsgCache.Account,
|
|
|
UserId: qrcodeMessage.UserId,
|
|
|
UserBaseId: qrcodeMessage.UserBaseId,
|
|
|
Account: qrcodeMessage.Account,
|
|
|
Platform: domain.LoginPlatformWeb,
|
|
|
CompanyId: qrmsgCache.CompanyId,
|
|
|
OrgId: qrmsgCache.OrgId,
|
|
|
}
|
|
|
// accessToken, err := loginToken.GenerateAccessToken()
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
// }
|
|
|
qrCache.Remove(qrmsgCache.Id)
|
|
|
// _ = accessToken
|
|
|
CompanyId: qrcodeMessage.CompanyId,
|
|
|
OrgId: qrcodeMessage.OrgId,
|
|
|
}
|
|
|
cache.Remove(queryParam.Key)
|
|
|
result, err := svr.getToken(loginToken)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
data := map[string]interface{}{
|
|
|
"isLogin": qrmsgCache.IsLogin,
|
|
|
"isLogin": qrcodeMessage.IsLogin,
|
|
|
"access": result["token"],
|
|
|
}
|
|
|
return data, nil
|
...
|
...
|
@@ -153,20 +144,15 @@ func (svr AuthService) AuthLoginQrcode(queryParam *query.QrcodeLoginStatusQuery) |
|
|
|
|
|
//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)
|
|
|
qrcodeMessage, err := qrCache.Get(bindingCmd.Key)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "您扫描的二维码无效,请确认后重新扫描")
|
|
|
}
|
|
|
if err := qrmsgCache.BindUser(bindingCmd.Operator); err != nil {
|
|
|
if err := qrcodeMessage.BindUser(bindingCmd.Operator); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := qrCache.Save(*qrmsgCache); err != nil {
|
|
|
if err := qrCache.Save(*qrcodeMessage); err != nil {
|
|
|
log.Logger.Error(err.Error())
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "登录失败,请重试")
|
|
|
}
|
...
|
...
|
@@ -721,19 +707,18 @@ func (svr AuthService) GetCompanyOrgsByUser(queryParam *query.GetCompanyOrgsByUs |
|
|
|
|
|
//GetQrcode 获取扫码登录需要的二维码
|
|
|
func (svr AuthService) GetQrcode() (interface{}, error) {
|
|
|
qrmsg := domain.QrcodeMessage{}
|
|
|
_, err := qrmsg.GenerateImageBase64() //imgBase64
|
|
|
qrcodeMessage := domain.QrcodeMessage{}
|
|
|
_, err := qrcodeMessage.Init() //imgBase64
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
qrCache := cache.LoginQrcodeCache{}
|
|
|
err = qrCache.Save(qrmsg)
|
|
|
err = qrCache.Save(qrcodeMessage)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
data := map[string]interface{}{
|
|
|
//"image": imgBase64,
|
|
|
"key": qrmsg.Token,
|
|
|
"key": qrcodeMessage.Token,
|
|
|
}
|
|
|
return data, nil
|
|
|
}
|
...
|
...
|
|