...
|
...
|
@@ -584,8 +584,8 @@ func LoginAuthBySecretKey(secretKey string) (protocol.LoginAuthToken, error) { |
|
|
err error
|
|
|
logintoken protocol.LoginAuthToken
|
|
|
// usercompanyid int64
|
|
|
userdata *models.User
|
|
|
companyData *models.Company
|
|
|
|
|
|
// companyData *models.Company
|
|
|
)
|
|
|
var uclientReturn *ucenter.ResponseLogin
|
|
|
uclientReturn, err = ucenter.RequestUCenterLoginBySecret(secretKey)
|
...
|
...
|
@@ -597,28 +597,7 @@ func LoginAuthBySecretKey(secretKey string) (protocol.LoginAuthToken, error) { |
|
|
},
|
|
|
}
|
|
|
}
|
|
|
|
|
|
userdata, err = models.GetUserByPhone(uclientReturn.Data.Phone)
|
|
|
if err != nil {
|
|
|
log.Debug("GetUserByPhone(%d) err:%s", uclientReturn.Data.Phone, err)
|
|
|
return logintoken, protocol.NewErrWithMessage("10201")
|
|
|
}
|
|
|
companyData, err = models.GetCompanyByUCenter(uclientReturn.Data.CompanyId)
|
|
|
if err != nil {
|
|
|
log.Error("获取company数据失败:%s", err)
|
|
|
return logintoken, protocol.NewErrWithMessage("10211")
|
|
|
}
|
|
|
if companyData.Enable == models.COMPANY_ENABLE_NO {
|
|
|
log.Error("公司未启用机会模块")
|
|
|
return logintoken, protocol.NewErrWithMessage("10212")
|
|
|
}
|
|
|
ucompany, err := models.GetUserCompanyBy(userdata.Id, companyData.Id)
|
|
|
if err != nil {
|
|
|
log.Error("获取user_company失败;%s", err)
|
|
|
return logintoken, protocol.NewErrWithMessage("10202")
|
|
|
}
|
|
|
|
|
|
businessAdminResp, err := serverplatform.GetuserAuthDo(ucompany.Id)
|
|
|
businessAdminResp, err := serverplatform.GetuserAuthDo(uclientReturn.Data.Muid)
|
|
|
if err != nil {
|
|
|
log.Error("向企业平台获取鉴权结果失败,err:%s", err)
|
|
|
return logintoken, protocol.NewErrWithMessage("1")
|
...
|
...
|
@@ -635,23 +614,50 @@ func LoginAuthBySecretKey(secretKey string) (protocol.LoginAuthToken, error) { |
|
|
log.Error("用户没有权限进行操作")
|
|
|
return logintoken, protocol.NewErrWithMessage("10210")
|
|
|
}
|
|
|
logintoken, _ = GenerateAuthToken(userdata.Id, companyData.Id, ucompany.Id)
|
|
|
//更新用户数据
|
|
|
userdata.Accid = uclientReturn.Data.Accid
|
|
|
userdata.Icon = uclientReturn.Data.Avatar
|
|
|
userdata.ImToken = uclientReturn.Data.Imtoken
|
|
|
userdata.NickName = uclientReturn.Data.NickName
|
|
|
userdata.CsAccount = uclientReturn.Data.CustomerAccount
|
|
|
userdata.LastLoginTime = time.Now()
|
|
|
err = models.UpdateUserById(userdata, []string{"Accid", "Icon", "ImToken", "NickName", "CsAccount", "LastLoginTime"})
|
|
|
if err != nil {
|
|
|
log.Error("更新用户user数据失败:%s", err)
|
|
|
}
|
|
|
ucompany.NickName = uclientReturn.Data.NickName
|
|
|
err = models.UpdateUserCompanyById(ucompany, []string{"NickName"})
|
|
|
// userdata, err = models.GetUserByPhone(uclientReturn.Data.Phone)
|
|
|
// if err != nil {
|
|
|
// log.Debug("GetUserByPhone(%d) err:%s", uclientReturn.Data.Phone, err)
|
|
|
// return logintoken, protocol.NewErrWithMessage("10201")
|
|
|
// }
|
|
|
// companyData, err = models.GetCompanyByUCenter(uclientReturn.Data.CompanyId)
|
|
|
// if err != nil {
|
|
|
// log.Error("获取company数据失败:%s", err)
|
|
|
// return logintoken, protocol.NewErrWithMessage("10211")
|
|
|
// }
|
|
|
// if companyData.Enable == models.COMPANY_ENABLE_NO {
|
|
|
// log.Error("公司未启用机会模块")
|
|
|
// return logintoken, protocol.NewErrWithMessage("10212")
|
|
|
// }
|
|
|
// ucompany, err := models.GetUserCompanyBy(userdata.Id, companyData.Id)
|
|
|
// if err != nil {
|
|
|
// log.Error("获取user_company失败;%s", err)
|
|
|
// return logintoken, protocol.NewErrWithMessage("10202")
|
|
|
// }
|
|
|
ucompany, err := models.GetUserCompanyById(uclientReturn.Data.Muid)
|
|
|
if err != nil {
|
|
|
log.Error("更新用户user_company数据失败:%s", err)
|
|
|
log.Error("获取user_company失败;%s", err)
|
|
|
return logintoken, protocol.NewErrWithMessage("10202")
|
|
|
}
|
|
|
InitPermission(ucompany.Id, userdata.Id)
|
|
|
logintoken, _ = GenerateAuthToken(ucompany.UserId, ucompany.CompanyId, ucompany.Id)
|
|
|
//更新用户数据
|
|
|
//用户数据的更新 交由数据同步的接口处理
|
|
|
// var userdata *models.User
|
|
|
// userdata.Id = ucompany.UserId
|
|
|
// userdata.Accid = uclientReturn.Data.Accid
|
|
|
// userdata.Icon = uclientReturn.Data.Avatar
|
|
|
// userdata.ImToken = uclientReturn.Data.Imtoken
|
|
|
// userdata.NickName = uclientReturn.Data.NickName
|
|
|
// userdata.CsAccount = uclientReturn.Data.CustomerAccount
|
|
|
// userdata.LastLoginTime = time.Now()
|
|
|
// err = models.UpdateUserById(userdata, []string{"Accid", "Icon", "ImToken", "NickName", "CsAccount", "LastLoginTime"})
|
|
|
// if err != nil {
|
|
|
// log.Error("更新用户user数据失败:%s", err)
|
|
|
// }
|
|
|
// ucompany.NickName = uclientReturn.Data.NickName
|
|
|
// err = models.UpdateUserCompanyById(ucompany, []string{"NickName"})
|
|
|
// if err != nil {
|
|
|
// log.Error("更新用户user_company数据失败:%s", err)
|
|
|
// }
|
|
|
InitPermission(ucompany.Id, ucompany.UserId)
|
|
|
return logintoken, err
|
|
|
} |
...
|
...
|
|