Skip to content

Commit a1aefd6

Browse files
Merge pull request #676 from jeroenheijmans/fix-missinng-hash-clearing-prevention
Use preventClearHashAfterLogin consistently
2 parents 60e2c6c + bfda151 commit a1aefd6

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

projects/lib/src/oauth-service.ts

+11-10
Original file line numberDiff line numberDiff line change
@@ -1268,6 +1268,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
12681268
}
12691269

12701270
return url;
1271+
12711272
}
12721273

12731274
initImplicitFlowInternal(
@@ -1506,32 +1507,32 @@ export class OAuthService extends AuthConfig implements OnDestroy {
15061507
(tokenResponse) => {
15071508
this.debug('refresh tokenResponse', tokenResponse);
15081509
this.storeAccessTokenResponse(
1509-
tokenResponse.access_token,
1510-
tokenResponse.refresh_token,
1510+
tokenResponse.access_token,
1511+
tokenResponse.refresh_token,
15111512
tokenResponse.expires_in,
15121513
tokenResponse.scope);
15131514

15141515
if (this.oidc && tokenResponse.id_token) {
1515-
this.processIdToken(tokenResponse.id_token, tokenResponse.access_token).
1516+
this.processIdToken(tokenResponse.id_token, tokenResponse.access_token).
15161517
then(result => {
15171518
this.storeIdToken(result);
1518-
1519+
15191520
this.eventsSubject.next(new OAuthSuccessEvent('token_received'));
15201521
this.eventsSubject.next(new OAuthSuccessEvent('token_refreshed'));
1521-
1522+
15221523
resolve(tokenResponse);
15231524
})
15241525
.catch(reason => {
15251526
this.eventsSubject.next(new OAuthErrorEvent('token_validation_error', reason));
15261527
console.error('Error validating tokens');
15271528
console.error(reason);
1528-
1529+
15291530
reject(reason);
15301531
});
15311532
} else {
15321533
this.eventsSubject.next(new OAuthSuccessEvent('token_received'));
15331534
this.eventsSubject.next(new OAuthSuccessEvent('token_refreshed'));
1534-
1535+
15351536
resolve(tokenResponse);
15361537
}
15371538
},
@@ -1654,7 +1655,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
16541655
.then(result => {
16551656
this.storeIdToken(result);
16561657
this.storeSessionState(sessionState);
1657-
if (this.clearHashAfterLogin) {
1658+
if (this.clearHashAfterLogin && !options.preventClearHashAfterLogin) {
16581659
location.hash = '';
16591660
}
16601661
this.eventsSubject.next(new OAuthSuccessEvent('token_received'));
@@ -1691,7 +1692,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
16911692
): boolean {
16921693
const savedNonce = this._storage.getItem('nonce');
16931694
if (savedNonce !== nonceInState) {
1694-
1695+
16951696
const err = 'Validating access_token failed, wrong state/nonce.';
16961697
console.error(err, savedNonce, nonceInState);
16971698
return false;
@@ -1718,7 +1719,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
17181719
if (options.onLoginError) {
17191720
options.onLoginError(parts);
17201721
}
1721-
if (this.clearHashAfterLogin) {
1722+
if (this.clearHashAfterLogin && !options.preventClearHashAfterLogin) {
17221723
location.hash = '';
17231724
}
17241725
}

0 commit comments

Comments
 (0)