Fix user impersonation requests

This commit is contained in:
Steven Polley 2018-07-27 13:29:31 -06:00
parent 0b898af164
commit 28b6efc18c
1 changed files with 6 additions and 3 deletions

View File

@ -80,9 +80,12 @@ func (req *Request) Do() error {
if req.CW.AuthAPIKey != "" { if req.CW.AuthAPIKey != "" {
httpreq.Header.Set("Authorization", req.CW.AuthAPIKey) httpreq.Header.Set("Authorization", req.CW.AuthAPIKey)
} else { //User impersonation } else { //User impersonation
httpreq.Header.Set("Cookie", fmt.Sprintf("companyName=%s", req.CW.CompanyName)) cookieCompanyName := http.Cookie{Name: "companyName", Value: req.CW.CompanyName}
httpreq.Header.Set("Cookie", fmt.Sprintf("memberHash=%s", req.CW.AuthMemberHash)) cookieMemberHash := http.Cookie{Name: "memberHash", Value: req.CW.AuthMemberHash}
httpreq.Header.Set("Cookie", fmt.Sprintf("MemberID=%s", req.CW.AuthUsername)) 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") httpreq.Header.Set("Content-Type", "application/json")
resp, err := client.Do(httpreq) resp, err := client.Do(httpreq)