@@ -226,40 +226,39 @@ export class AuthService implements OnDestroy {
226
226
} ) . finally ( ( ) => {
227
227
this . isLoading$ . next ( false ) ;
228
228
} ) ;
229
- // this.cryptrClient.handleRefreshTokens().then((res) => {
230
- // console.log(`handlerefreshTokens ${res === true}`);
231
- // console.log(res);
232
- // this.updateCurrentAuthState(res === true);
233
- // }).catch((error) => {
234
- // this.updateCurrentAuthState(false);
235
- // }).finally(() => {
236
- // this.isLoading$.next(false);
237
- // });
238
229
}
239
230
}
240
231
241
- fullAuthenticateProcess ( stateUrl ?: string ) : Observable < boolean | UrlTree > {
232
+ private defaultAuthenticationCallback ( isAuthenticated : boolean , stateUrl ?: string ) : boolean {
242
233
const { audience, default_locale } = this . config ( ) ;
243
234
const redirectUri = audience . concat ( stateUrl || '' ) ;
244
- // const tree = this.router.parseUrl(stateUrl)
245
- // const newTree = this.cleanUrlTree(tree, stateUrl)
235
+ if ( isAuthenticated ) {
236
+ return true ;
237
+ } else {
238
+ if ( this . configFactory . get ( ) . has_ssr ) {
239
+ this . signInWithRedirect ( DEFAULT_SCOPE , default_locale , redirectUri ) ;
240
+ } else {
241
+ this . signInWithRedirect ( ) ;
242
+ }
243
+ return false ;
244
+ }
245
+ }
246
+
247
+ fullAuthenticateProcess (
248
+ stateUrl ?: string ,
249
+ callback ?: ( isAuthenticated : boolean , stateUrl ?: string ) => boolean
250
+ ) : Observable < boolean | UrlTree > {
246
251
return combineLatest (
247
252
[ this . isLoading$ , this . authenticated$ ]
248
253
) . pipe (
249
254
filter ( ( [ isLoading , isAuthenticated ] ) => {
250
255
return ! isLoading ;
251
256
} ) ,
252
257
map ( ( [ isLoading , isAuthenticated ] ) => {
253
- if ( isAuthenticated ) {
254
- this . cleanRouteState ( ) ;
255
- return true ;
258
+ if ( callback ) {
259
+ return callback ( isAuthenticated , stateUrl ) ;
256
260
} else {
257
- if ( this . configFactory . get ( ) . has_ssr ) {
258
- this . signInWithRedirect ( DEFAULT_SCOPE , default_locale , redirectUri ) ;
259
- } else {
260
- this . signInWithRedirect ( ) ;
261
- }
262
- return false ;
261
+ return this . defaultAuthenticationCallback ( isAuthenticated , stateUrl ) ;
263
262
}
264
263
} )
265
264
) ;
0 commit comments