|
@@ -26,67 +26,23 @@ const (
|
|
|
)
|
|
|
|
|
|
var (
|
|
|
- base_url = global.CONFIG.HTFutures.SSOAuthHost
|
|
|
- client HttpClient = CreateDefault()
|
|
|
+ base_url = global.CONFIG.HTFutures.SSOAuthHost
|
|
|
+ clientToken HttpClient[string] = CreateDefault[string]()
|
|
|
+ clientUser HttpClient[UserInfoResp] = CreateDefault[UserInfoResp]()
|
|
|
)
|
|
|
|
|
|
type UserInfoResp struct {
|
|
|
- UserId string `json:"userId"`
|
|
|
- CreatedAt string `json:"createdAt"`
|
|
|
- UpdatedAt string `json:"updatedAt"`
|
|
|
- Status string `json:"status"`
|
|
|
- WorkStatus string `json:"workStatus"`
|
|
|
- ExternalId string `json:"externalId"`
|
|
|
- Email string `json:"email"`
|
|
|
- Phone string `json:"phone"`
|
|
|
- PhoneCountryCode string `json:"phoneCountryCode"`
|
|
|
- Username string `json:"username"`
|
|
|
- Name string `json:"name"`
|
|
|
- Nickname string `json:"nickname"`
|
|
|
- Photo string `json:"photo"`
|
|
|
- LoginsCount int `json:"loginsCount"`
|
|
|
- LastLogin string `json:"lastLogin"`
|
|
|
- LastIp string `json:"lastIp"`
|
|
|
- Gender string `json:"gender"`
|
|
|
- EmailVerified bool `json:"emailVerified"`
|
|
|
- PhoneVerified bool `json:"phoneVerified"`
|
|
|
- PasswordLastSetAt string `json:"passwordLastSetAt"`
|
|
|
- Birthdate string `json:"birthdate"`
|
|
|
- Country string `json:"country"`
|
|
|
- Province string `json:"province"`
|
|
|
- City string `json:"city"`
|
|
|
- Address string `json:"address"`
|
|
|
- StreetAddress string `json:"streetAddress"`
|
|
|
- PostalCode string `json:"postalCode"`
|
|
|
- Company string `json:"company"`
|
|
|
- Browser string `json:"browser"`
|
|
|
- Device string `json:"device"`
|
|
|
- GivenName string `json:"givenName"`
|
|
|
- FamilyName string `json:"familyName"`
|
|
|
- MiddleName string `json:"middleName"`
|
|
|
- Profile string `json:"profile"`
|
|
|
- PreferredUsername string `json:"preferredUsername"`
|
|
|
- Website string `json:"website"`
|
|
|
- Zoneinfo string `json:"zoneinfo"`
|
|
|
- Locale string `json:"locale"`
|
|
|
- Formatted string `json:"formatted"`
|
|
|
- Region string `json:"region"`
|
|
|
- UserSourceType string `json:"userSourceType"`
|
|
|
- UserSourceId string `json:"userSourceId"`
|
|
|
- LastLoginApp string `json:"lastLoginApp"`
|
|
|
- MainDepartmentId string `json:"mainDepartmentId"`
|
|
|
- LastMfaTime string `json:"lastMfaTime"`
|
|
|
- PasswordSecurityLevel int `json:"passwordSecurityLevel"`
|
|
|
- ResetPasswordOnNextLogin bool `json:"resetPasswordOnNextLogin"`
|
|
|
- RegisterSource []string `json:"registerSource"`
|
|
|
- DepartmentIds []string `json:"departmentIds"`
|
|
|
- Identities []string `json:"identities"`
|
|
|
- IdentityNumber string `json:"identityNumber"`
|
|
|
- CustomData string `json:"customData"`
|
|
|
- MetadataSource string `json:"metadataSource"`
|
|
|
- PostIdList string `json:"postIdList"`
|
|
|
- StatusChangedAt string `json:"statusChangedAt"`
|
|
|
- TenantId string `json:"tenantId"`
|
|
|
+ UserId string `json:"userId"`
|
|
|
+ Status string `json:"status"`
|
|
|
+ WorkStatus string `json:"workStatus"`
|
|
|
+ Username string `json:"username"`
|
|
|
+ Name string `json:"name"`
|
|
|
+ Nickname string `json:"nickname"`
|
|
|
+ LastLogin string `json:"lastLogin"`
|
|
|
+ LastIp string `json:"lastIp"`
|
|
|
+ GivenName string `json:"givenName"`
|
|
|
+ FamilyName string `json:"familyName"`
|
|
|
+ MiddleName string `json:"middleName"`
|
|
|
}
|
|
|
|
|
|
func ssoLogin(code string, systemType string) (token string, userInfo UserInfoResp, err error) {
|
|
@@ -148,7 +104,6 @@ func LoginCRM(code string) (resp response.LoginResp, err error, errMsg string) {
|
|
|
global.FILE_LOG.Error("生成登录session失败:" + err.Error())
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
// 记录两方session的绑定信息
|
|
|
thirdSession := &eta.SysThirdSession{
|
|
|
ID: 0,
|
|
@@ -218,7 +173,8 @@ func LoginEta(code string) (resp response.LoginResp, err error, errMsg string) {
|
|
|
global.FILE_LOG.Error("生成登录session失败:" + err.Error())
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
+ str, _ := json.Marshal(resp)
|
|
|
+ global.FILE_LOG.Info(fmt.Sprintf("session json 序列化结果为:%s", str))
|
|
|
// 记录两方session的绑定信息
|
|
|
thirdSession := &eta.SysThirdSession{
|
|
|
ID: 0,
|
|
@@ -440,12 +396,12 @@ func GetToken(code string, systemType string) (token string, err error) {
|
|
|
params := url.Values{}
|
|
|
params.Add(authCode, code)
|
|
|
params.Add(sysType, systemType)
|
|
|
- resp, err := client.PostFromData(urlStr, params)
|
|
|
+ resp, err := clientToken.PostFromData(urlStr, params)
|
|
|
if err != nil {
|
|
|
global.FILE_LOG.Error("获取token失败:" + err.Error())
|
|
|
return
|
|
|
}
|
|
|
- if resp.Code != 200 {
|
|
|
+ if resp.Code != 0 {
|
|
|
global.FILE_LOG.Error("请求接口应答异常:" + resp.Message)
|
|
|
err = errors.New("接口异常应答:" + resp.Message)
|
|
|
return
|
|
@@ -459,20 +415,21 @@ func GetUserInfo(token string, systemType string) (userinfo UserInfoResp, err er
|
|
|
params := url.Values{}
|
|
|
params.Add(accessToken, token)
|
|
|
params.Add(sysType, systemType)
|
|
|
- resp, err := client.PostFromData(urlStr, params)
|
|
|
+ resp, err := clientUser.PostFromData(urlStr, params)
|
|
|
if err != nil {
|
|
|
global.FILE_LOG.Error("获取用户信息失败:" + err.Error())
|
|
|
return
|
|
|
}
|
|
|
- if resp.Code != 200 {
|
|
|
+ if resp.Code != 0 {
|
|
|
global.FILE_LOG.Error("请求接口应答异常:" + resp.Message)
|
|
|
err = errors.New("接口异常应答:" + resp.Message)
|
|
|
return
|
|
|
}
|
|
|
- err = json.Unmarshal([]byte(resp.Data), &userinfo)
|
|
|
- if err != nil {
|
|
|
- global.FILE_LOG.Error("解析用户信息失败:" + err.Error())
|
|
|
- return
|
|
|
- }
|
|
|
+ userinfo = resp.Data
|
|
|
+ //err = json.Unmarshal([]byte(resp.Data), &userinfo)
|
|
|
+ //if err != nil {
|
|
|
+ // global.FILE_LOG.Error("解析用户信息失败:" + err.Error())
|
|
|
+ // return
|
|
|
+ //}
|
|
|
return
|
|
|
}
|