From 2a50d716f1d236c5752d058e85a7fe34c398e47f Mon Sep 17 00:00:00 2001 From: Chneemann Date: Wed, 2 Apr 2025 20:43:55 +0200 Subject: [PATCH] feat: migrate logout functionality to Django Rest in SidebarComponent --- .../components/sidebar/sidebar.component.ts | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/app/shared/components/sidebar/sidebar.component.ts b/src/app/shared/components/sidebar/sidebar.component.ts index b28bf96..c9f54b7 100644 --- a/src/app/shared/components/sidebar/sidebar.component.ts +++ b/src/app/shared/components/sidebar/sidebar.component.ts @@ -3,8 +3,7 @@ import { Component, OnInit } from '@angular/core'; import { NavigationEnd, Router, RouterModule } from '@angular/router'; import { TranslateModule } from '@ngx-translate/core'; import { LanguageService } from '../../../services/language.service'; -import { LoginService } from '../../../services/login.service'; -import { FirebaseService } from '../../../services/firebase.service'; +import { AuthService } from '../../../services/auth.service'; @Component({ selector: 'app-sidebar', @@ -19,8 +18,7 @@ export class SidebarComponent implements OnInit { constructor( private router: Router, public languageService: LanguageService, - private loginService: LoginService, - private firebaseService: FirebaseService + private authService: AuthService ) {} /** @@ -32,19 +30,6 @@ export class SidebarComponent implements OnInit { this.getCurrentPath(); } - /** - * Logs out the current user and navigates to the login page. - * - * Calls the logout method of the LoginService with the current user ID as - * its argument. This will remove the user ID from the local storage and - * perform any other necessary cleanup operations. - * - * The user is then navigated to the login page. - */ - logout() { - this.loginService.logout(this.firebaseService.getCurrentUserId()); - } - /** * Subscribes to router events and updates the currentPath property * with the current route's URL, excluding the leading slash, whenever @@ -57,4 +42,14 @@ export class SidebarComponent implements OnInit { } }); } + + /** + * Logs out the current user by calling the logout method of the AuthService. + * + * This will clear the user's authentication token and any associated session + * data, and navigate the user to the logout page. + */ + logout() { + this.authService.logout(); + } }