Implementation of login and logout mechanisms.
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
<h1>Disconnection...</h1>
|
||||
<mat-spinner></mat-spinner>
|
||||
@@ -0,0 +1,6 @@
|
||||
:host {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
15
sportshub-gui/src/app/components/logout/logout.component.ts
Normal file
15
sportshub-gui/src/app/components/logout/logout.component.ts
Normal 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();
|
||||
}
|
||||
}
|
||||
29
sportshub-gui/src/app/components/logout/logout.module.ts
Normal file
29
sportshub-gui/src/app/components/logout/logout.module.ts
Normal 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 {}
|
||||
16
sportshub-gui/src/app/components/logout/logout.service.ts
Normal file
16
sportshub-gui/src/app/components/logout/logout.service.ts
Normal 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(['/']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user