Skip to content
Snippets Groups Projects
Commit 6b875098 authored by Lukasz Lopatowski's avatar Lukasz Lopatowski
Browse files

Merge branch 'handle-wrong-password-error' into 'develop'

added error handle

See merge request !107
parents 0de427fa 82c3e817
Branches
Tags
4 merge requests!184Develop,!119Develop,!108Develop,!107added error handle
......@@ -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>
......
......@@ -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';
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment