Skip to content

Commit

Permalink
fix(oauth): check for window parent correctly in ouath without popup
Browse files Browse the repository at this point in the history
window.parent is equal to itself when there is no parent, so it will always be truthy. Need to check
that the window has a separate parent instead.

AFFECTS PACKAGES:
@esri/arcgis-rest-auth
  • Loading branch information
Noah Mulfinger committed Jan 4, 2018
1 parent 28a3cca commit a27bb7d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/arcgis-rest-auth/src/UserSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ export class UserSession implements IAuthenticationManager {
return undefined;
}

if (win.parent) {
if (win !== win.parent) {
win.parent[`__ESRI_REST_AUTH_HANDLER_${clientId}`](error, oauthInfo);
win.close();
return undefined;
Expand Down Expand Up @@ -592,12 +592,12 @@ export class UserSession implements IAuthenticationManager {
}

if (!this._pendingTokenRequests[this.portal]) {
this._pendingTokenRequests[
this.portal
] = this.refreshSession().then(session => {
this._pendingTokenRequests[this.portal] = null;
return session.token;
});
this._pendingTokenRequests[this.portal] = this.refreshSession().then(
session => {
this._pendingTokenRequests[this.portal] = null;
return session.token;
}
);
}

return this._pendingTokenRequests[this.portal];
Expand Down
6 changes: 6 additions & 0 deletions packages/arcgis-rest-auth/test/UserSession.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,9 @@ describe("UserSession", () => {
location: {
href:
"https://example-app.com/redirect-uri#access_token=token&expires_in=1209600&username=casey"
},
get parent() {
return this;
}
};

Expand Down Expand Up @@ -566,6 +569,9 @@ describe("UserSession", () => {
location: {
href:
"https://example-app.com/redirect-uri#error=Invalid_Signin&error_description=Invalid_Signin"
},
get parent() {
return this;
}
};

Expand Down

0 comments on commit a27bb7d

Please sign in to comment.