From 5e5fbd937708cd8e0c79a9765bd89b849e201b2d Mon Sep 17 00:00:00 2001 From: Takiguchi Date: Sat, 18 Jan 2020 14:30:17 +0100 Subject: [PATCH] Add a control to avoid error notif at login failure. --- .../src/app/core/interceptors/unauthorized.interceptor.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/ts/src/app/core/interceptors/unauthorized.interceptor.ts b/src/main/ts/src/app/core/interceptors/unauthorized.interceptor.ts index 5610e41..0207776 100644 --- a/src/main/ts/src/app/core/interceptors/unauthorized.interceptor.ts +++ b/src/main/ts/src/app/core/interceptors/unauthorized.interceptor.ts @@ -6,6 +6,8 @@ import { catchError } from 'rxjs/operators'; import { AuthService } from '../services/auth.service'; import { NotificationsComponent } from '../notifications/notifications.component'; +const REG_URL_LOGIN = /^https?:\/\/.*(:\d{1,5})?\/api\/account\/login$/; + @Injectable() export class UnauthorizedInterceptor implements HttpInterceptor { constructor( @@ -18,7 +20,9 @@ export class UnauthorizedInterceptor implements HttpInterceptor { if (err.status === 401) { this.authService.setAnonymous(); this.router.navigate(['/login']); - window.setTimeout(() => NotificationsComponent.error('Veuillez vous authentifier pour réaliser cette action.'), 500); + if (!err.url.match(REG_URL_LOGIN)) { + window.setTimeout(() => NotificationsComponent.error('Veuillez vous authentifier pour réaliser cette action.'), 500); + } } const error = (err.error && err.error.message) || err.statusText;