Verified Commit e3079db5 authored by Raphael Ochsenbein's avatar Raphael Ochsenbein
Browse files

Only try to convert tokens, if data exists -> and display correct error message

parent d2a5872d
......@@ -22,20 +22,26 @@
<div class="bx--grid">
<div class="bx--row">
<ng-container *ngIf="oidcError && (oidcError.signInError || oidcError.silentRenewError)">
<div class="bx--col-xs-12 bx--col-sm-6">
<h2>OIDC Error</h2>
<ibm-code-snippet display="multi">{{ oidcError | json }}</ibm-code-snippet>
</div>
</ng-container>
<ng-container *ngIf="oidcError && (oidcError.signInError || oidcError.silentRenewError)">
<div class="bx--col-xs-12 bx--col-sm-6 error">
<h2>OIDC Error</h2>
<ibm-code-snippet display="multi">{{ oidcError | json }}</ibm-code-snippet>
</div>
</ng-container>
<ng-container *ngIf="apiError">
<div class="bx--col-xs-12 bx--col-sm-6">
<h2>API Error</h2>
<ibm-code-snippet display="multi">{{ apiError | json }}</ibm-code-snippet>
</div>
<ng-container *ngIf="apiError">
<div class="bx--col-xs-12 bx--col-sm-6 error">
<h2>API Error</h2>
<ibm-code-snippet display="multi">{{ apiError | json }}</ibm-code-snippet>
</div>
</ng-container>
</ng-container>
<ng-container *ngIf="decodeError">
<div class="bx--col-xs-12 bx--col-sm-6 error">
<h2>Token Error</h2>
<ibm-code-snippet display="multi">{{ decodeError }}</ibm-code-snippet>
</div>
</ng-container>
</div>
<hr/>
</div>
......
......@@ -73,12 +73,15 @@ export class AppComponent implements OnDestroy {
this.identitySub = this.oidcFacade.identity$.subscribe((data) => {
this.identity = data;
this.decodeError = null;
try {
this.decodedIdToken = jwt_decode(data.id_token);
this.decodedAccessToken = jwt_decode(data.access_token);
} catch (e) {
this.decodeError = e;
if (data) {
try {
this.decodedIdToken = jwt_decode(data.id_token);
this.decodedAccessToken = jwt_decode(data.access_token);
} catch (e) {
this.decodeError = e.toString();
}
}
});
}
......
......@@ -13,4 +13,8 @@ body {
// fixes
.bx--snippet--multi {
background: #1d1d1d;
.error & {
border: 1px solid #e94c47;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment