add user impersonation via username and password.

This commit is contained in:
2018-07-26 21:30:23 -06:00
parent 0eca613e65
commit 9e107cb487
2 changed files with 71 additions and 4 deletions

View File

@ -77,7 +77,13 @@ func (req *Request) Do() error {
if err != nil {
return fmt.Errorf("could not construct http request: %s", err)
}
httpreq.Header.Set("Authorization", req.CW.Auth)
if req.CW.AuthAPIKey != "" {
httpreq.Header.Set("Authorization", req.CW.AuthAPIKey)
} else { //User impersonation
httpreq.Header.Set("Cookie", fmt.Sprintf("companyName=%s", req.CW.CompanyName))
httpreq.Header.Set("Cookie", fmt.Sprintf("memberHash=%s", req.CW.AuthMemberHash))
httpreq.Header.Set("Cookie", fmt.Sprintf("MemberID=%s", req.CW.AuthUsername))
}
httpreq.Header.Set("Content-Type", "application/json")
resp, err := client.Do(httpreq)
if err != nil {