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 764a89d..5610e41 100644 --- a/src/main/ts/src/app/core/interceptors/unauthorized.interceptor.ts +++ b/src/main/ts/src/app/core/interceptors/unauthorized.interceptor.ts @@ -4,6 +4,7 @@ import { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent } from '@angular/c import { Observable, throwError } from 'rxjs'; import { catchError } from 'rxjs/operators'; import { AuthService } from '../services/auth.service'; +import { NotificationsComponent } from '../notifications/notifications.component'; @Injectable() export class UnauthorizedInterceptor implements HttpInterceptor { @@ -17,6 +18,7 @@ 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); } const error = (err.error && err.error.message) || err.statusText; diff --git a/src/main/ts/src/app/posts/create-update/create-update-post.component.ts b/src/main/ts/src/app/posts/create-update/create-update-post.component.ts index a553aa2..d944d09 100644 --- a/src/main/ts/src/app/posts/create-update/create-update-post.component.ts +++ b/src/main/ts/src/app/posts/create-update/create-update-post.component.ts @@ -160,10 +160,16 @@ export class CreateUpdatePostComponent implements OnInit { if (this.model.key) { this.createUpdatePostService.updatePost(this.model).subscribe(post => { NotificationsComponent.success('Modification enregistrée'); + }, error => { + console.log(error); + NotificationsComponent.error('Une erreur est survenue lors de l\'enregistrement des modifications.'); }); } else { this.createUpdatePostService.addPost(this.model).subscribe(post => { this.router.navigate([`/posts/update/${post.key}`]); + }, error => { + console.log(error); + NotificationsComponent.error('Une erreur est survenue lors de la création du post.'); }); } } else {