Fix user impersonation requests

This commit is contained in:
Steven Polley 2018-07-27 13:29:31 -06:00
parent 0b898af164
commit 28b6efc18c

View File

@ -80,9 +80,12 @@ func (req *Request) Do() error {
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))
cookieCompanyName := http.Cookie{Name: "companyName", Value: req.CW.CompanyName}
cookieMemberHash := http.Cookie{Name: "memberHash", Value: req.CW.AuthMemberHash}
cookieMemberID := http.Cookie{Name: "memberID", Value: req.CW.AuthUsername}
httpreq.AddCookie(&cookieCompanyName)
httpreq.AddCookie(&cookieMemberHash)
httpreq.AddCookie(&cookieMemberID)
}
httpreq.Header.Set("Content-Type", "application/json")
resp, err := client.Do(httpreq)