Add a control to avoid error notif at login failure.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user