Skip to content

Commit

Permalink
fix: fix impersonation issue (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
santese authored Apr 26, 2023
1 parent 92d4bfe commit 25c89ec
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@ export class Addigy {
@param {string} payloadName - Name of the profile
@param {string} userDefinedName - Name of the filter to be displayed in the User
@param {string} pluginBundleId - Bundle ID of the plugin to be used for filtering
*/
async createWebContentFilterPolicy(
Expand Down Expand Up @@ -1499,14 +1499,16 @@ export class Addigy {
orgId: string,
): Promise<IAddigyInternalAuthObject> {
let postBody: any = {
orgid: orgId,
parent_orgid: authObject.orgId,
child_orgid: orgId,
user_email: authObject.emailAddress,
}

try {
let res = await this._addigyRequest('https://prod.addigy.com/impersonate_org/', {
let res = await this._addigyRequest('https://app.addigy.com/api/impersonation', {
headers: {
Cookie: `auth_token=${authObject.authToken};`,
origin: 'https://app-prod.addigy.com',
Cookie: `prod_auth_token=${authObject.authToken};`,
origin: 'https://app.addigy.com',
},
method: 'POST',
json: postBody,
Expand All @@ -1517,7 +1519,7 @@ export class Addigy {
authToken: res.headers['set-cookie']
.find(
(e: string) =>
e.includes('auth_token') && !e.includes('original_auth_token'),
e.includes('prod_auth_token') && !e.includes('original_auth_token'),
)
.split('auth_token=')[1]
.split(';')[0],
Expand Down

0 comments on commit 25c89ec

Please sign in to comment.