Implementation of login and logout mechanisms.

This commit is contained in:
Florian THIERRY
2023-12-05 14:31:07 +01:00
parent c095cdab3a
commit 9f40a6c782
17 changed files with 228 additions and 13 deletions

View File

@@ -0,0 +1,2 @@
<h1>Disconnection...</h1>
<mat-spinner></mat-spinner>

View File

@@ -0,0 +1,6 @@
:host {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}

View File

@@ -0,0 +1,15 @@
import {Component, inject, OnInit} from "@angular/core";
import {LogoutService} from "./logout.service";
@Component({
selector: 'app-logout',
templateUrl: './logout.component.html',
styleUrls: ['./logout.component.scss']
})
export class LogoutComponent implements OnInit {
private logoutService = inject(LogoutService);
ngOnInit(): void {
this.logoutService.logout();
}
}

View File

@@ -0,0 +1,29 @@
import {NgModule} from "@angular/core";
import {RouterModule} from "@angular/router";
import {LogoutComponent} from "./logout.component";
import {MatProgressSpinnerModule} from "@angular/material/progress-spinner";
import {LogoutService} from "./logout.service";
const routes = [
{
path: '',
component: LogoutComponent
}
];
@NgModule({
declarations: [
LogoutComponent
],
providers: [
LogoutService
],
imports: [
RouterModule.forChild(routes),
MatProgressSpinnerModule
],
exports: [
LogoutComponent
]
})
export class LogoutModule {}

View File

@@ -0,0 +1,16 @@
import {Injectable} from "@angular/core";
import {AuthenticationService} from "../../core/services/authentication.service";
import {Router} from "@angular/router";
@Injectable()
export class LogoutService {
constructor(
private authenticationService: AuthenticationService,
private router: Router
) {}
logout(): void {
this.authenticationService.setAnonymous();
this.router.navigate(['/']);
}
}