|
|
@@ -6,7 +6,6 @@ import (
|
|
|
"io/ioutil"
|
|
|
"log"
|
|
|
"net/http"
|
|
|
- "net/url"
|
|
|
"strings"
|
|
|
|
|
|
//"dashoo.cn/business2/userRole"
|
|
|
@@ -34,22 +33,30 @@ type iamResult struct {
|
|
|
UserAD string `json:"userName"`
|
|
|
UserNo string `json:"accountName"`
|
|
|
}
|
|
|
+type params struct {
|
|
|
+ AppCode string `json:"appCode"`
|
|
|
+ Secret string `json:"secret"`
|
|
|
+ Code string `json:"code"`
|
|
|
+}
|
|
|
|
|
|
func (s *IamLoginService) HandleIamLogin(appCode string, secret string, code string) iam {
|
|
|
|
|
|
Url := utils.Cfg.MustValue("Iam", "iamUrl")
|
|
|
//Url := "http://iam.api.dgyt.petrochina/api/iam/loginex"
|
|
|
-
|
|
|
- v := make(url.Values)
|
|
|
- v.Add("appCode", appCode)
|
|
|
- v.Add("secret", secret)
|
|
|
- v.Add("code", code)
|
|
|
+ var params params
|
|
|
+ params.AppCode = appCode
|
|
|
+ params.Secret = secret
|
|
|
+ params.Code = code
|
|
|
+ //v := make(url.Values)
|
|
|
+ //v.Add("appCode", appCode)
|
|
|
+ //v.Add("secret", secret)
|
|
|
+ //v.Add("code", code)
|
|
|
|
|
|
//resp, err := http.PostForm(Url, v)
|
|
|
- iamString, _ := json.Marshal(v)
|
|
|
- vString := string(iamString)
|
|
|
+ iamString, _ := json.Marshal(params)
|
|
|
+ paramsString := string(iamString)
|
|
|
client := &http.Client{}
|
|
|
- req, err := http.NewRequest("POST", Url, strings.NewReader(vString))
|
|
|
+ req, err := http.NewRequest("POST", Url, strings.NewReader(paramsString))
|
|
|
req.Header.Add("Content-Type", "application/json")
|
|
|
resp, err := client.Do(req)
|
|
|
if err != nil {
|