diff --git a/src/app/app-modules/core/services/auth-guard.service.ts b/src/app/app-modules/core/services/auth-guard.service.ts index 4719d6e0..d4e618c7 100644 --- a/src/app/app-modules/core/services/auth-guard.service.ts +++ b/src/app/app-modules/core/services/auth-guard.service.ts @@ -22,7 +22,8 @@ import { Injectable } from '@angular/core'; import { CanActivate, Router } from '@angular/router'; -import { map } from 'rxjs/operators'; +import { catchError, map } from 'rxjs/operators'; +import { of } from 'rxjs'; import { AuthService } from './auth.service'; @Injectable() export class AuthGuard implements CanActivate { @@ -37,7 +38,8 @@ export class AuthGuard implements CanActivate { res && res.statusCode === 200 && res.data ? true : this.router.createUrlTree(['/login']) - ) + ), + catchError(() => of(this.router.createUrlTree(['/login']))) ); } } diff --git a/src/app/app-modules/login/login.component.ts b/src/app/app-modules/login/login.component.ts index 26bcdf10..1d44dae0 100644 --- a/src/app/app-modules/login/login.component.ts +++ b/src/app/app-modules/login/login.component.ts @@ -203,7 +203,13 @@ export class LoginComponent implements OnInit, AfterViewInit { }, err => { this.resetCaptcha(); - this.confirmationService.alert(err, 'error'); + const message = [err?.error?.errorMessage, err?.message].find( + msg => !!msg + ); + this.confirmationService.alert( + message || 'Login request failed. Please try again.', + 'error' + ); } ); }