diff --git a/angular.json b/angular.json index c76d25a..061f7b1 100644 --- a/angular.json +++ b/angular.json @@ -28,6 +28,7 @@ } ], "styles": [ + "@angular/material/prebuilt-themes/azure-blue.css", "src/styles.css" ], "scripts": [] @@ -92,6 +93,7 @@ } ], "styles": [ + "@angular/material/prebuilt-themes/magenta-violet.css", "src/styles.css" ], "scripts": [] diff --git a/package.json b/package.json index 59d6047..501d495 100644 --- a/package.json +++ b/package.json @@ -12,10 +12,12 @@ "private": true, "dependencies": { "@angular/animations": "^18.2.0", + "@angular/cdk": "^18.2.14", "@angular/common": "^18.2.0", "@angular/compiler": "^18.2.0", "@angular/core": "^18.2.0", "@angular/forms": "^18.2.0", + "@angular/material": "^18.2.14", "@angular/platform-browser": "^18.2.0", "@angular/platform-browser-dynamic": "^18.2.0", "@angular/platform-server": "^18.2.0", @@ -49,4 +51,4 @@ "karma-jasmine-html-reporter": "~2.1.0", "typescript": "~5.5.2" } -} +} \ No newline at end of file diff --git a/src/app/app.component.html b/src/app/app.component.html index d12ecd3..9db0daf 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,5 +1,5 @@ -@if (isBrowser()) { +@if (isBrowser() && (authService.isSessionExpired() && authService.isAuthenticated())) { Votre session a expiré ! Il va falloir se reconnecter.
diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 6d1e015..b609473 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -7,7 +7,7 @@ import {DialogModule} from 'primeng/dialog'; import {isPlatformBrowser} from '@angular/common'; import {Button} from 'primeng/button'; import {AuthService} from './auth.service'; -import {CookieService} from 'ngx-cookie-service'; +import {Router} from '@angular/router'; @Component({ selector: 'app-root', @@ -23,8 +23,8 @@ export class AppComponent implements OnInit { isSessionExpired: boolean = false; constructor(@Inject(PLATFORM_ID) private platformId: object, - private authService: AuthService, - private cookieService: CookieService) { + protected authService: AuthService, + private router: Router,) { } isBrowser(): boolean { @@ -34,6 +34,7 @@ export class AppComponent implements OnInit { setSessionExpiredFalse(): void { this.isSessionExpired = false; this.authService.setSessionExpired(false); + this.router.navigate(['/logout']); } ngOnInit(): void { diff --git a/src/app/app.config.ts b/src/app/app.config.ts index a955765..becc995 100644 --- a/src/app/app.config.ts +++ b/src/app/app.config.ts @@ -5,6 +5,7 @@ import {routes} from './app.routes'; import {provideClientHydration} from '@angular/platform-browser'; import {provideHttpClient, withFetch} from '@angular/common/http'; import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; +import { provideAnimationsAsync } from '@angular/platform-browser/animations/async'; export const appConfig: ApplicationConfig = { providers: [ @@ -12,5 +13,5 @@ export const appConfig: ApplicationConfig = { provideRouter(routes), provideClientHydration(), provideHttpClient(withFetch()), - importProvidersFrom([BrowserAnimationsModule])] + importProvidersFrom([BrowserAnimationsModule]), provideAnimationsAsync()] }; diff --git a/src/app/auth.service.ts b/src/app/auth.service.ts index 55196b9..3471c95 100644 --- a/src/app/auth.service.ts +++ b/src/app/auth.service.ts @@ -1,5 +1,4 @@ import {Injectable} from '@angular/core'; -import {CookieService} from 'ngx-cookie-service'; import {Author} from './models/author'; import {BehaviorSubject} from 'rxjs'; import {DateTime} from 'luxon'; @@ -11,7 +10,7 @@ export class AuthService { private sessionExpiredSubject = new BehaviorSubject(false); sessionExpired$ = this.sessionExpiredSubject.asObservable(); - constructor(private cookieService: CookieService) { + constructor() { this.checkSessionExpiration(); } diff --git a/src/app/components/post-home/post-home.component.html b/src/app/components/post-home/post-home.component.html index c5613d0..6aaabc2 100644 --- a/src/app/components/post-home/post-home.component.html +++ b/src/app/components/post-home/post-home.component.html @@ -5,7 +5,7 @@ {{ category }} Publié le {{ date | date : "dd/MM/yyyy à HH:mm" }} {{ description }} - +