@@ -171,14 +171,15 @@ export class OAuthService extends AuthConfig {
171
171
this . restartRefreshTimerIfStillLoggedIn ( ) ;
172
172
}
173
173
174
+
174
175
/**
175
176
* Convenience method that first calls `loadDiscoveryDocument(...)` and
176
177
* directly chains using the `then(...)` part of the promise to call
177
178
* the `tryLogin(...)` method.
178
179
*
179
180
* @param options LoginOptions to pass through to `tryLogin(...)`
180
181
*/
181
- public loadDiscoveryDocumentAndTryLogin ( options : LoginOptions = null ) {
182
+ public loadDiscoveryDocumentAndTryLogin ( options : LoginOptions = null ) : Promise < boolean > {
182
183
return this . loadDiscoveryDocument ( ) . then ( doc => {
183
184
return this . tryLogin ( options ) ;
184
185
} ) ;
@@ -191,7 +192,7 @@ export class OAuthService extends AuthConfig {
191
192
*
192
193
* @param options LoginOptions to pass through to `tryLogin(...)`
193
194
*/
194
- public loadDiscoveryDocumentAndLogin ( options : LoginOptions = null ) {
195
+ public loadDiscoveryDocumentAndLogin ( options : LoginOptions = null ) : Promise < boolean > {
195
196
return this . loadDiscoveryDocumentAndTryLogin ( options ) . then ( _ => {
196
197
if ( ! this . hasValidIdToken ( ) || ! this . hasValidAccessToken ( ) ) {
197
198
this . initImplicitFlow ( ) ;
@@ -1258,7 +1259,7 @@ export class OAuthService extends AuthConfig {
1258
1259
*
1259
1260
* @param options Optional options.
1260
1261
*/
1261
- public tryLogin ( options : LoginOptions = null ) : Promise < void > {
1262
+ public tryLogin ( options : LoginOptions = null ) : Promise < boolean > {
1262
1263
options = options || { } ;
1263
1264
1264
1265
let parts : object ;
@@ -1303,13 +1304,13 @@ export class OAuthService extends AuthConfig {
1303
1304
}
1304
1305
1305
1306
if ( this . requestAccessToken && ! accessToken ) {
1306
- return Promise . resolve ( ) ;
1307
+ return Promise . resolve ( false ) ;
1307
1308
}
1308
1309
if ( this . requestAccessToken && ! options . disableOAuth2StateCheck && ! state ) {
1309
- return Promise . resolve ( ) ;
1310
+ return Promise . resolve ( false ) ;
1310
1311
}
1311
1312
if ( this . oidc && ! idToken ) {
1312
- return Promise . resolve ( ) ;
1313
+ return Promise . resolve ( false ) ;
1313
1314
}
1314
1315
1315
1316
if ( this . sessionChecksEnabled && ! sessionState ) {
@@ -1346,8 +1347,10 @@ export class OAuthService extends AuthConfig {
1346
1347
if ( this . clearHashAfterLogin && ! options . preventClearHashAfterLogin ) {
1347
1348
location . hash = '' ;
1348
1349
}
1350
+
1349
1351
this . callOnTokenReceivedIfExists ( options ) ;
1350
- return Promise . resolve ( ) ;
1352
+ return Promise . resolve ( true ) ;
1353
+
1351
1354
}
1352
1355
1353
1356
return this . processIdToken ( idToken , accessToken )
@@ -1373,6 +1376,7 @@ export class OAuthService extends AuthConfig {
1373
1376
this . eventsSubject . next ( new OAuthSuccessEvent ( 'token_received' ) ) ;
1374
1377
this . callOnTokenReceivedIfExists ( options ) ;
1375
1378
this . inImplicitFlow = false ;
1379
+ return true ;
1376
1380
} )
1377
1381
. catch ( reason => {
1378
1382
this . eventsSubject . next (
0 commit comments