Skip to content

Commit

Permalink
fix(auth): decode username when parsing response from OAuth
Browse files Browse the repository at this point in the history
Usernames with @ symbols are returned from OAuth as %40, so we need to decode them with
decodeURIComponent.

AFFECTS PACKAGES:
@esri/arcgis-rest-auth

ISSUES CLOSED: #165
  • Loading branch information
Noah Mulfinger committed Mar 29, 2018
1 parent 3650bd2 commit e0c2a44
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
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 @@ -376,7 +376,7 @@ export class UserSession implements IAuthenticationManager {
const expires = new Date(
Date.now() + parseInt(match[2], 10) * 1000 - 60 * 1000
);
const username = match[3];
const username = decodeURIComponent(match[3]);

return completeSignIn(null, {
token,
Expand Down
6 changes: 3 additions & 3 deletions packages/arcgis-rest-auth/test/UserSession.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ describe("UserSession", () => {
const MockWindow = {
location: {
href:
"https://example-app.com/redirect-uri#access_token=token&expires_in=1209600&username=c@sey&persist=true"
"https://example-app.com/redirect-uri#access_token=token&expires_in=1209600&username=c%40sey&persist=true"
},
get parent() {
return this;
Expand Down Expand Up @@ -527,7 +527,7 @@ describe("UserSession", () => {
},
location: {
href:
"https://example-app.com/redirect-uri#access_token=token&expires_in=1209600&username=c@sey"
"https://example-app.com/redirect-uri#access_token=token&expires_in=1209600&username=c%40sey"
}
};

Expand Down Expand Up @@ -557,7 +557,7 @@ describe("UserSession", () => {
},
location: {
href:
"https://example-app.com/redirect-uri#access_token=token&expires_in=1209600&username=c@sey"
"https://example-app.com/redirect-uri#access_token=token&expires_in=1209600&username=c%40sey"
}
};

Expand Down

0 comments on commit e0c2a44

Please sign in to comment.