feat: migrate logout functionality to Django Rest in SidebarComponent
This commit is contained in:
parent
45a40a3980
commit
2a50d716f1
1 changed files with 12 additions and 17 deletions
|
|
@ -3,8 +3,7 @@ import { Component, OnInit } from '@angular/core';
|
||||||
import { NavigationEnd, Router, RouterModule } from '@angular/router';
|
import { NavigationEnd, Router, RouterModule } from '@angular/router';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { LanguageService } from '../../../services/language.service';
|
import { LanguageService } from '../../../services/language.service';
|
||||||
import { LoginService } from '../../../services/login.service';
|
import { AuthService } from '../../../services/auth.service';
|
||||||
import { FirebaseService } from '../../../services/firebase.service';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-sidebar',
|
selector: 'app-sidebar',
|
||||||
|
|
@ -19,8 +18,7 @@ export class SidebarComponent implements OnInit {
|
||||||
constructor(
|
constructor(
|
||||||
private router: Router,
|
private router: Router,
|
||||||
public languageService: LanguageService,
|
public languageService: LanguageService,
|
||||||
private loginService: LoginService,
|
private authService: AuthService
|
||||||
private firebaseService: FirebaseService
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -32,19 +30,6 @@ export class SidebarComponent implements OnInit {
|
||||||
this.getCurrentPath();
|
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
|
* Subscribes to router events and updates the currentPath property
|
||||||
* with the current route's URL, excluding the leading slash, whenever
|
* 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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue