diff --git a/src/app/welcome/link-account/link-account.component.html b/src/app/welcome/link-account/link-account.component.html index 1ab303ed37f4a43c7b9de3afd3519ec4b878ef37..2d75205238a0c5f83811c5aa3ebcb229b4d79d89 100644 --- a/src/app/welcome/link-account/link-account.component.html +++ b/src/app/welcome/link-account/link-account.component.html @@ -43,7 +43,7 @@ margin-top: 50px; <button type="submit" class="btn btn-primary" (click)="submit()">{{ 'ACCOUNT_LINKING.CONFIRM' | translate }} </button> - + <div *ngIf="error" class="alert alert-danger" style="margin-top: 20px">{{error}}</div> </form> <br> </div> diff --git a/src/app/welcome/link-account/link-account.component.ts b/src/app/welcome/link-account/link-account.component.ts index 1f4f967c4fb0b2b058724e575469136354574555..cb60e030f051c169a57b0f1a72394101cee6157d 100644 --- a/src/app/welcome/link-account/link-account.component.ts +++ b/src/app/welcome/link-account/link-account.component.ts @@ -3,6 +3,7 @@ import {User} from '../../model'; import {ActivatedRoute, Router} from '@angular/router'; import jwtDecode from 'jwt-decode'; import {AuthService} from '../../auth/auth.service'; +import {TranslateService} from '@ngx-translate/core'; @Component({ @@ -14,11 +15,13 @@ export class LinkAccountComponent implements OnInit, OnDestroy { public user: User; private token: string; public password: string; + public error: string; constructor( private readonly route: ActivatedRoute, private readonly authService: AuthService, - private readonly router: Router + private readonly router: Router, + private translate: TranslateService, ) { } @@ -52,9 +55,24 @@ export class LinkAccountComponent implements OnInit, OnDestroy { ).subscribe( () => { this.router.navigate(['/']); + }, + err => { + this.error = this.translate.instant(this.getMessage(err)); } ) } + private getMessage(err: any): string { + switch (err['status']) { + case 401: + return 'LOGIN.LOGIN_FAILURE_MESSAGE'; + case 406: + return 'LOGIN.APPLICATION_UNDER_MAINTENANCE_MESSAGE'; + case 409: + return 'GENERIC_MESSAGE.UNAVAILABLE_MESSAGE'; + default: + return 'GENERIC_MESSAGE.UNAVAILABLE_MESSAGE'; + } + } }