Skip to content

Commit

Permalink
Merge pull request #245 from Esri/bug/233
Browse files Browse the repository at this point in the history
fix(:bug:): treat ArcGIS Online orgs as equivalent to www.arcgis.com
  • Loading branch information
jgravois authored Jul 23, 2018
2 parents daeec31 + 5d3c349 commit b2c5cdc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/arcgis-rest-auth/src/UserSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ export class UserSession implements IAuthenticationManager {
*/
getToken(url: string) {
if (
/^https?:\/\/www\.arcgis\.com\/sharing\/rest\/?/.test(this.portal) &&
/^https?:\/\/\S+\.arcgis\.com\/sharing\/rest/.test(this.portal) &&
/^https?:\/\/\S+\.arcgis\.com.+/.test(url)
) {
return this.getFreshToken();
Expand Down
21 changes: 21 additions & 0 deletions packages/arcgis-rest-auth/test/UserSession.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,27 @@ describe("UserSession", () => {
});
});

it("should return unexpired tokens when an org url is passed", done => {
const session = new UserSession({
clientId: "id",
token: "token",
tokenExpires: TOMORROW,
portal: "https://custom.maps.arcgis.com/sharing/rest"
});

session
.getToken(
"https://services1.arcgis.com/MOCK_ORG/arcgis/rest/services/Private_Service/FeatureServer"
)
.then(token => {
expect(token).toBe("token");
done();
})
.catch(e => {
fail(e);
});
});

it("should return unexpired tokens for the configured portal domain", done => {
const session = new UserSession({
clientId: "id",
Expand Down

0 comments on commit b2c5cdc

Please sign in to comment.