@@ -1893,7 +1893,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
1893
1893
if ( ! this . oidc ) {
1894
1894
this . eventsSubject . next ( new OAuthSuccessEvent ( 'token_received' ) ) ;
1895
1895
if ( this . clearHashAfterLogin && ! options . preventClearHashAfterLogin ) {
1896
- location . hash = '' ;
1896
+ this . clearLocationHash ( ) ;
1897
1897
}
1898
1898
1899
1899
this . callOnTokenReceivedIfExists ( options ) ;
@@ -1918,7 +1918,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
1918
1918
this . storeIdToken ( result ) ;
1919
1919
this . storeSessionState ( sessionState ) ;
1920
1920
if ( this . clearHashAfterLogin && ! options . preventClearHashAfterLogin ) {
1921
- location . hash = '' ;
1921
+ this . clearLocationHash ( ) ;
1922
1922
}
1923
1923
this . eventsSubject . next ( new OAuthSuccessEvent ( 'token_received' ) ) ;
1924
1924
this . callOnTokenReceivedIfExists ( options ) ;
@@ -1989,7 +1989,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
1989
1989
options . onLoginError ( parts ) ;
1990
1990
}
1991
1991
if ( this . clearHashAfterLogin && ! options . preventClearHashAfterLogin ) {
1992
- location . hash = '' ;
1992
+ this . clearLocationHash ( ) ;
1993
1993
}
1994
1994
}
1995
1995
@@ -2695,4 +2695,15 @@ export class OAuthService extends AuthConfig implements OnDestroy {
2695
2695
) ;
2696
2696
} ) ;
2697
2697
}
2698
+
2699
+ /**
2700
+ * Clear location.hash if it's present
2701
+ */
2702
+ private clearLocationHash ( ) {
2703
+ // Checking for empty hash is necessary for Firefox
2704
+ // as setting an empty hash to an empty string adds # to the URL
2705
+ if ( location . hash != '' ) {
2706
+ location . hash = '' ;
2707
+ }
2708
+ }
2698
2709
}
0 commit comments