diff --git a/packages/core/state/src/lib/+state/authn/authn.effects.ts b/packages/core/state/src/lib/+state/authn/authn.effects.ts index ba906b69..39da8a50 100644 --- a/packages/core/state/src/lib/+state/authn/authn.effects.ts +++ b/packages/core/state/src/lib/+state/authn/authn.effects.ts @@ -110,6 +110,9 @@ export class AuthnEffects { ofType(authnActions.signInRequest), switchMap(({ payload }) => { return this.authnService.signIn(payload).pipe( + tap((result) => { + console.log('Result for signin:', result); + }), map( ({ access_token: token = null, diff --git a/packages/modules/main/src/lib/components/template/private-template.component.ts b/packages/modules/main/src/lib/components/template/private-template.component.ts index ebdb91dd..9f9b3a83 100644 --- a/packages/modules/main/src/lib/components/template/private-template.component.ts +++ b/packages/modules/main/src/lib/components/template/private-template.component.ts @@ -8,7 +8,7 @@ import { SubSink } from 'subsink'; import { NotifierService } from '@vcl/ng-vcl'; -import { AppFacade } from '@console-core/state'; +import { AppFacade, AuthnFacade } from '@console-core/state'; import { Notifier } from '../../utils'; @@ -31,14 +31,26 @@ export class PrivateTemplateComponent constructor( private readonly notifier: NotifierService, - private readonly appFacade: AppFacade + private readonly appFacade: AppFacade, + private readonly authFacade: AuthnFacade ) { super(notifier); this.handleNotifications(this.notifications$); } ngOnInit(): void { - this.subscriptions.sink = this.notifications$.subscribe(); + this.subscriptions.add(this.notifications$.subscribe()); + this.subscriptions.add( + this.authFacade.expiresIn$.subscribe((expiresIn) => { + // console.log("Expires in", expiresIn); + const expires = new Date(expiresIn as string); + const now = new Date(); + + if (now.getTime() > expires.getTime()) { + this.authFacade.signOut(); + } + }) + ); } ngOnDestroy(): void {