Better comments in requests.go to explain user impersonation
This commit is contained in:
parent
b6d96444b5
commit
04e889c444
@ -64,7 +64,8 @@ func (req *Request) Do() error {
|
|||||||
return fmt.Errorf("could not build url %s: %s", req.RestAction, err)
|
return fmt.Errorf("could not build url %s: %s", req.RestAction, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
//If pagination parameters are not being specified, then don't include them in the URL - not all endpoints will accept page and pagesize, they will 400 - bad request
|
//If pagination parameters are not being specified, then don't include them in the URL
|
||||||
|
//Not all endpoints will accept page and pagesize, they return http status 400 - bad request
|
||||||
if req.Page == 0 || req.PageSize == 0 {
|
if req.Page == 0 || req.PageSize == 0 {
|
||||||
cwurl.RawQuery = req.URLValues.Encode()
|
cwurl.RawQuery = req.URLValues.Encode()
|
||||||
} else {
|
} else {
|
||||||
@ -77,9 +78,9 @@ func (req *Request) Do() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not construct http request: %s", err)
|
return fmt.Errorf("could not construct http request: %s", err)
|
||||||
}
|
}
|
||||||
if req.CW.AuthAPIKey != "" {
|
if req.CW.AuthAPIKey != "" { //Standard API keys
|
||||||
httpreq.Header.Set("Authorization", req.CW.AuthAPIKey)
|
httpreq.Header.Set("Authorization", req.CW.AuthAPIKey)
|
||||||
} else { //User impersonation
|
} else { //User impersonation using username + password
|
||||||
cookieCompanyName := http.Cookie{Name: "companyName", Value: req.CW.CompanyName}
|
cookieCompanyName := http.Cookie{Name: "companyName", Value: req.CW.CompanyName}
|
||||||
cookieMemberHash := http.Cookie{Name: "memberHash", Value: req.CW.AuthMemberHash}
|
cookieMemberHash := http.Cookie{Name: "memberHash", Value: req.CW.AuthMemberHash}
|
||||||
cookieMemberID := http.Cookie{Name: "memberID", Value: req.CW.AuthUsername}
|
cookieMemberID := http.Cookie{Name: "memberID", Value: req.CW.AuthUsername}
|
||||||
|
Loading…
Reference in New Issue
Block a user