|
@@ -584,8 +584,8 @@ func LoginAuthBySecretKey(secretKey string) (protocol.LoginAuthToken, error) { |
|
@@ -584,8 +584,8 @@ func LoginAuthBySecretKey(secretKey string) (protocol.LoginAuthToken, error) { |
584
|
err error
|
584
|
err error
|
585
|
logintoken protocol.LoginAuthToken
|
585
|
logintoken protocol.LoginAuthToken
|
586
|
// usercompanyid int64
|
586
|
// usercompanyid int64
|
587
|
- userdata *models.User
|
|
|
588
|
- companyData *models.Company
|
587
|
+
|
|
|
588
|
+ // companyData *models.Company
|
589
|
)
|
589
|
)
|
590
|
var uclientReturn *ucenter.ResponseLogin
|
590
|
var uclientReturn *ucenter.ResponseLogin
|
591
|
uclientReturn, err = ucenter.RequestUCenterLoginBySecret(secretKey)
|
591
|
uclientReturn, err = ucenter.RequestUCenterLoginBySecret(secretKey)
|
|
@@ -597,28 +597,7 @@ func LoginAuthBySecretKey(secretKey string) (protocol.LoginAuthToken, error) { |
|
@@ -597,28 +597,7 @@ func LoginAuthBySecretKey(secretKey string) (protocol.LoginAuthToken, error) { |
597
|
},
|
597
|
},
|
598
|
}
|
598
|
}
|
599
|
}
|
599
|
}
|
600
|
-
|
|
|
601
|
- userdata, err = models.GetUserByPhone(uclientReturn.Data.Phone)
|
|
|
602
|
- if err != nil {
|
|
|
603
|
- log.Debug("GetUserByPhone(%d) err:%s", uclientReturn.Data.Phone, err)
|
|
|
604
|
- return logintoken, protocol.NewErrWithMessage("10201")
|
|
|
605
|
- }
|
|
|
606
|
- companyData, err = models.GetCompanyByUCenter(uclientReturn.Data.CompanyId)
|
|
|
607
|
- if err != nil {
|
|
|
608
|
- log.Error("获取company数据失败:%s", err)
|
|
|
609
|
- return logintoken, protocol.NewErrWithMessage("10211")
|
|
|
610
|
- }
|
|
|
611
|
- if companyData.Enable == models.COMPANY_ENABLE_NO {
|
|
|
612
|
- log.Error("公司未启用机会模块")
|
|
|
613
|
- return logintoken, protocol.NewErrWithMessage("10212")
|
|
|
614
|
- }
|
|
|
615
|
- ucompany, err := models.GetUserCompanyBy(userdata.Id, companyData.Id)
|
|
|
616
|
- if err != nil {
|
|
|
617
|
- log.Error("获取user_company失败;%s", err)
|
|
|
618
|
- return logintoken, protocol.NewErrWithMessage("10202")
|
|
|
619
|
- }
|
|
|
620
|
-
|
|
|
621
|
- businessAdminResp, err := serverplatform.GetuserAuthDo(ucompany.Id)
|
600
|
+ businessAdminResp, err := serverplatform.GetuserAuthDo(uclientReturn.Data.Muid)
|
622
|
if err != nil {
|
601
|
if err != nil {
|
623
|
log.Error("向企业平台获取鉴权结果失败,err:%s", err)
|
602
|
log.Error("向企业平台获取鉴权结果失败,err:%s", err)
|
624
|
return logintoken, protocol.NewErrWithMessage("1")
|
603
|
return logintoken, protocol.NewErrWithMessage("1")
|
|
@@ -635,23 +614,50 @@ func LoginAuthBySecretKey(secretKey string) (protocol.LoginAuthToken, error) { |
|
@@ -635,23 +614,50 @@ func LoginAuthBySecretKey(secretKey string) (protocol.LoginAuthToken, error) { |
635
|
log.Error("用户没有权限进行操作")
|
614
|
log.Error("用户没有权限进行操作")
|
636
|
return logintoken, protocol.NewErrWithMessage("10210")
|
615
|
return logintoken, protocol.NewErrWithMessage("10210")
|
637
|
}
|
616
|
}
|
638
|
- logintoken, _ = GenerateAuthToken(userdata.Id, companyData.Id, ucompany.Id)
|
|
|
639
|
- //更新用户数据
|
|
|
640
|
- userdata.Accid = uclientReturn.Data.Accid
|
|
|
641
|
- userdata.Icon = uclientReturn.Data.Avatar
|
|
|
642
|
- userdata.ImToken = uclientReturn.Data.Imtoken
|
|
|
643
|
- userdata.NickName = uclientReturn.Data.NickName
|
|
|
644
|
- userdata.CsAccount = uclientReturn.Data.CustomerAccount
|
|
|
645
|
- userdata.LastLoginTime = time.Now()
|
|
|
646
|
- err = models.UpdateUserById(userdata, []string{"Accid", "Icon", "ImToken", "NickName", "CsAccount", "LastLoginTime"})
|
|
|
647
|
- if err != nil {
|
|
|
648
|
- log.Error("更新用户user数据失败:%s", err)
|
|
|
649
|
- }
|
|
|
650
|
- ucompany.NickName = uclientReturn.Data.NickName
|
|
|
651
|
- err = models.UpdateUserCompanyById(ucompany, []string{"NickName"})
|
617
|
+ // userdata, err = models.GetUserByPhone(uclientReturn.Data.Phone)
|
|
|
618
|
+ // if err != nil {
|
|
|
619
|
+ // log.Debug("GetUserByPhone(%d) err:%s", uclientReturn.Data.Phone, err)
|
|
|
620
|
+ // return logintoken, protocol.NewErrWithMessage("10201")
|
|
|
621
|
+ // }
|
|
|
622
|
+ // companyData, err = models.GetCompanyByUCenter(uclientReturn.Data.CompanyId)
|
|
|
623
|
+ // if err != nil {
|
|
|
624
|
+ // log.Error("获取company数据失败:%s", err)
|
|
|
625
|
+ // return logintoken, protocol.NewErrWithMessage("10211")
|
|
|
626
|
+ // }
|
|
|
627
|
+ // if companyData.Enable == models.COMPANY_ENABLE_NO {
|
|
|
628
|
+ // log.Error("公司未启用机会模块")
|
|
|
629
|
+ // return logintoken, protocol.NewErrWithMessage("10212")
|
|
|
630
|
+ // }
|
|
|
631
|
+ // ucompany, err := models.GetUserCompanyBy(userdata.Id, companyData.Id)
|
|
|
632
|
+ // if err != nil {
|
|
|
633
|
+ // log.Error("获取user_company失败;%s", err)
|
|
|
634
|
+ // return logintoken, protocol.NewErrWithMessage("10202")
|
|
|
635
|
+ // }
|
|
|
636
|
+ ucompany, err := models.GetUserCompanyById(uclientReturn.Data.Muid)
|
652
|
if err != nil {
|
637
|
if err != nil {
|
653
|
- log.Error("更新用户user_company数据失败:%s", err)
|
638
|
+ log.Error("获取user_company失败;%s", err)
|
|
|
639
|
+ return logintoken, protocol.NewErrWithMessage("10202")
|
654
|
}
|
640
|
}
|
655
|
- InitPermission(ucompany.Id, userdata.Id)
|
641
|
+ logintoken, _ = GenerateAuthToken(ucompany.UserId, ucompany.CompanyId, ucompany.Id)
|
|
|
642
|
+ //更新用户数据
|
|
|
643
|
+ //用户数据的更新 交由数据同步的接口处理
|
|
|
644
|
+ // var userdata *models.User
|
|
|
645
|
+ // userdata.Id = ucompany.UserId
|
|
|
646
|
+ // userdata.Accid = uclientReturn.Data.Accid
|
|
|
647
|
+ // userdata.Icon = uclientReturn.Data.Avatar
|
|
|
648
|
+ // userdata.ImToken = uclientReturn.Data.Imtoken
|
|
|
649
|
+ // userdata.NickName = uclientReturn.Data.NickName
|
|
|
650
|
+ // userdata.CsAccount = uclientReturn.Data.CustomerAccount
|
|
|
651
|
+ // userdata.LastLoginTime = time.Now()
|
|
|
652
|
+ // err = models.UpdateUserById(userdata, []string{"Accid", "Icon", "ImToken", "NickName", "CsAccount", "LastLoginTime"})
|
|
|
653
|
+ // if err != nil {
|
|
|
654
|
+ // log.Error("更新用户user数据失败:%s", err)
|
|
|
655
|
+ // }
|
|
|
656
|
+ // ucompany.NickName = uclientReturn.Data.NickName
|
|
|
657
|
+ // err = models.UpdateUserCompanyById(ucompany, []string{"NickName"})
|
|
|
658
|
+ // if err != nil {
|
|
|
659
|
+ // log.Error("更新用户user_company数据失败:%s", err)
|
|
|
660
|
+ // }
|
|
|
661
|
+ InitPermission(ucompany.Id, ucompany.UserId)
|
656
|
return logintoken, err
|
662
|
return logintoken, err
|
657
|
} |
663
|
} |