From 13b6537c9c6ebdab0d9f470583cf3b7f4e324463 Mon Sep 17 00:00:00 2001 From: Art Date: Fri, 17 Sep 2021 21:09:52 +0300 Subject: [PATCH] 142. Login component - HttpErrorResponse (#18) --- .../src/app/component/login/login.component.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/support-portal-frontend/src/app/component/login/login.component.ts b/support-portal-frontend/src/app/component/login/login.component.ts index a2416cd..11120bb 100644 --- a/support-portal-frontend/src/app/component/login/login.component.ts +++ b/support-portal-frontend/src/app/component/login/login.component.ts @@ -5,7 +5,7 @@ import {NotificationService} from "../../service/notification.service"; import {NotificationType} from "../../notification/notification-type"; import {Subscription} from "rxjs"; import {UserLogin} from "../../dto/user-login"; -import {HttpResponse} from "@angular/common/http"; +import {HttpErrorResponse, HttpResponse} from "@angular/common/http"; import {User} from "../../model/user"; @Component({ @@ -46,6 +46,11 @@ export class LoginComponent implements OnInit, OnDestroy { this.router.navigateByUrl('/user/management'); this.showLoading = false; + }, + (errorResponse: HttpErrorResponse) => { + console.log(errorResponse); + this.sendErrorNotification(errorResponse.error.message); + this.showLoading = false; } ); @@ -55,4 +60,7 @@ export class LoginComponent implements OnInit, OnDestroy { ngOnDestroy(): void { } + private sendErrorNotification(message: string) { + this.notificationService.notify(NotificationType.ERROR, message ? message : 'AN ERROR OCCURRED. PLEASE TRY AGAIN') + } }