all files / src/ open-id-connect-user-debug.ts

100% Statements 13/13
100% Branches 2/2
100% Functions 3/3
100% Lines 12/12
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27                              
import { autoinject, customElement } from 'aurelia-framework';
import OpenIdConnectUserBlock from './open-id-connect-user-block';
 
@autoinject
@customElement('open-id-connect-user-debug')
export default class extends OpenIdConnectUserBlock {
 
  public async loginSilent() {
    try {
      this.openIdConnect.loginSilent();
    } catch (err) {
      if (err.error !== 'login_required') {
        // TODO: Check the JavaScript specification on Error and check
        // the OpenID Connect specification for the nesting of an error
        // inside the err object.
        throw err;
      }
 
      this.login();
    }
  }
 
  public get stringifiedUser(): string {
    return JSON.stringify(this.user, undefined, 2);
  }
}