Angular-auth-oidc-client: How do I detect when session expired?

Created on 3 Aug 2018  路  4Comments  路  Source: damienbod/angular-auth-oidc-client

Im sorry, this is not really an issue - I am the issue :) - but I cant figure out how to detected when the session/login expires.

I tried this in the app component, but it never seemed to get fired:

ngOnInit() {
    this.isAuthorizedSubscription = this.oidcSecurityService.getIsAuthorized().subscribe(
      (isAuthorized: boolean) => {
        if (this.isAuthorized && !isAuthorized) {
          // session expired - lockout the user
          this.dialog.open(SessionExpiredDialogComponent, {
            disableClose: false,
            role: 'alertdialog'
          });
        }
        console.log(`isAuth = ${isAuthorized}`);
        this.isAuthorized = isAuthorized;
      });
  }
enhancement

Most helpful comment

Thinking about adding an event or method for this

All 4 comments

Thinking about adding an event or method for this

I like the idea of having an event for this... @damienbod shall we target this?

@FabianGosebrink new branch with this alone, easy to test

this.oidcSecurityService.getIsAuthorized() should now work in version 6.0.12

Was this page helpful?
0 / 5 - 0 ratings

Related issues

toddtsic picture toddtsic  路  4Comments

jhossy picture jhossy  路  4Comments

vit100 picture vit100  路  4Comments

Roman1991 picture Roman1991  路  4Comments

Expelz picture Expelz  路  4Comments