@@ -942,7 +942,7 @@ export class OAuthService
942
942
return this . createAndSaveNonce ( ) . then ( ( nonce : any ) => {
943
943
944
944
if ( state ) {
945
- state = nonce + ';' + state ;
945
+ state = nonce + this . config . nonceStateSeparator + state ;
946
946
}
947
947
else {
948
948
state = nonce ;
@@ -1116,6 +1116,16 @@ export class OAuthService
1116
1116
1117
1117
this . debug ( 'parsed url' , parts ) ;
1118
1118
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
+
1119
1129
if ( parts [ 'error' ] ) {
1120
1130
this . debug ( 'error trying to login' ) ;
1121
1131
this . handleLoginError ( options , parts ) ;
@@ -1125,8 +1135,7 @@ export class OAuthService
1125
1135
}
1126
1136
1127
1137
let accessToken = parts [ 'access_token' ] ;
1128
- let idToken = parts [ 'id_token' ] ;
1129
- let state = decodeURIComponent ( parts [ 'state' ] ) ;
1138
+ let idToken = parts [ 'id_token' ] ;
1130
1139
let sessionState = parts [ 'session_state' ] ;
1131
1140
let grantedScopes = parts [ 'scope' ] ;
1132
1141
@@ -1145,20 +1154,6 @@ export class OAuthService
1145
1154
+ 'does not contain a session_state claim' ) ;
1146
1155
}
1147
1156
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];
1162
1157
1163
1158
if ( this . requestAccessToken && ! options . disableOAuth2StateCheck ) {
1164
1159
let success = this . validateNonceForAccessToken ( accessToken , nonceInState ) ;
0 commit comments