Skip to content

Commit e448314

Browse files
committed
Add support for hash location strategy in code flow
1 parent 41442e7 commit e448314

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

projects/lib/src/oauth-service.ts

+18-17
Original file line numberDiff line numberDiff line change
@@ -1380,24 +1380,8 @@ export class OAuthService extends AuthConfig implements OnDestroy {
13801380
}
13811381
}
13821382

1383-
1384-
private parseQueryString(queryString: string): object {
1385-
if (!queryString || queryString.length === 0) {
1386-
return {};
1387-
}
1388-
1389-
if (queryString.charAt(0) === '?') {
1390-
queryString = queryString.substr(1);
1391-
}
1392-
1393-
return this.urlHelper.parseQueryString(queryString);
1394-
1395-
1396-
}
1397-
13981383
public tryLoginCodeFlow(): Promise<void> {
1399-
1400-
const parts = this.parseQueryString(window.location.search)
1384+
const parts = this.getCodePartsFromUrl(window.location.search);
14011385

14021386
const code = parts['code'];
14031387
const state = parts['state'];
@@ -1445,6 +1429,23 @@ export class OAuthService extends AuthConfig implements OnDestroy {
14451429
}
14461430
}
14471431

1432+
/**
1433+
* Retrieve the returned auth code from the redirect uri that has been called.
1434+
* If required also check hash, as we could use hash location strategy.
1435+
*/
1436+
private getCodePartsFromUrl(queryString: string): object {
1437+
if (!queryString || queryString.length === 0) {
1438+
return this.urlHelper.getHashFragmentParams();
1439+
}
1440+
1441+
// normalize query string
1442+
if (queryString.charAt(0) === '?') {
1443+
queryString = queryString.substr(1);
1444+
}
1445+
1446+
return this.urlHelper.parseQueryString(queryString);
1447+
}
1448+
14481449
/**
14491450
* Get token using an intermediate code. Works for the Authorization Code flow.
14501451
*/

0 commit comments

Comments
 (0)