Skip to content

Commit

Permalink
Add support for hash location strategy in code flow
Browse files Browse the repository at this point in the history
  • Loading branch information
gingters committed Sep 24, 2019
1 parent 41442e7 commit e448314
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions projects/lib/src/oauth-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1380,24 +1380,8 @@ export class OAuthService extends AuthConfig implements OnDestroy {
}
}


private parseQueryString(queryString: string): object {
if (!queryString || queryString.length === 0) {
return {};
}

if (queryString.charAt(0) === '?') {
queryString = queryString.substr(1);
}

return this.urlHelper.parseQueryString(queryString);


}

public tryLoginCodeFlow(): Promise<void> {

const parts = this.parseQueryString(window.location.search)
const parts = this.getCodePartsFromUrl(window.location.search);

const code = parts['code'];
const state = parts['state'];
Expand Down Expand Up @@ -1445,6 +1429,23 @@ export class OAuthService extends AuthConfig implements OnDestroy {
}
}

/**
* Retrieve the returned auth code from the redirect uri that has been called.
* If required also check hash, as we could use hash location strategy.
*/
private getCodePartsFromUrl(queryString: string): object {
if (!queryString || queryString.length === 0) {
return this.urlHelper.getHashFragmentParams();
}

// normalize query string
if (queryString.charAt(0) === '?') {
queryString = queryString.substr(1);
}

return this.urlHelper.parseQueryString(queryString);
}

/**
* Get token using an intermediate code. Works for the Authorization Code flow.
*/
Expand Down

0 comments on commit e448314

Please sign in to comment.