@@ -942,7 +942,7 @@ export class OAuthService
942942 return this . createAndSaveNonce ( ) . then ( ( nonce : any ) => {
943943
944944 if ( state ) {
945- state = nonce + ';' + state ;
945+ state = nonce + this . config . nonceStateSeparator + state ;
946946 }
947947 else {
948948 state = nonce ;
@@ -1116,6 +1116,16 @@ export class OAuthService
11161116
11171117 this . debug ( 'parsed url' , parts ) ;
11181118
1119+ let state = decodeURIComponent ( parts [ 'state' ] ) ;
1120+ let nonceInState = state ;
1121+ let idx = state . indexOf ( this . config . nonceStateSeparator ) ;
1122+
1123+ if ( idx > - 1 ) {
1124+ nonceInState = state . substr ( 0 , idx ) ;
1125+ this . state = state . substr ( idx + this . config . nonceStateSeparator . length ) ;
1126+ }
1127+
1128+
11191129 if ( parts [ 'error' ] ) {
11201130 this . debug ( 'error trying to login' ) ;
11211131 this . handleLoginError ( options , parts ) ;
@@ -1125,8 +1135,7 @@ export class OAuthService
11251135 }
11261136
11271137 let accessToken = parts [ 'access_token' ] ;
1128- let idToken = parts [ 'id_token' ] ;
1129- let state = decodeURIComponent ( parts [ 'state' ] ) ;
1138+ let idToken = parts [ 'id_token' ] ;
11301139 let sessionState = parts [ 'session_state' ] ;
11311140 let grantedScopes = parts [ 'scope' ] ;
11321141
@@ -1145,20 +1154,6 @@ export class OAuthService
11451154 + 'does not contain a session_state claim' ) ;
11461155 }
11471156
1148- let nonceInState = state ;
1149- let idx = state . indexOf ( ';' ) ;
1150-
1151- if ( idx > - 1 ) {
1152- nonceInState = state . substr ( 0 , idx ) ;
1153- this . state = state . substr ( idx + 1 ) ;
1154- }
1155- /*
1156- let stateParts = state.split(';');
1157- if (stateParts.length > 1) {
1158- this.state = stateParts[1];
1159- }
1160- */
1161- // let nonceInState = stateParts[0];
11621157
11631158 if ( this . requestAccessToken && ! options . disableOAuth2StateCheck ) {
11641159 let success = this . validateNonceForAccessToken ( accessToken , nonceInState ) ;
0 commit comments