Refactor tutorial service for public access and enhance authentication handling

This commit is contained in:
liosha84
2025-07-06 19:37:32 +03:00
parent c39571ad70
commit 2ee97f8c86
25 changed files with 217 additions and 325 deletions
@@ -61,6 +61,7 @@ export class MainComponent implements OnInit{
isLoggedIn = false;
showAdminBoard = false;
showModeratorBoard = false;
showUserBoard = false;
username?: string;
eventBusSub?: Subscription;
@@ -74,12 +75,9 @@ export class MainComponent implements OnInit{
constructor(private router: Router,private http: HttpClient) {
}
goToHome() {
this.router.navigate(['main/home']);
}
ngOnInit(): void {
this.isLoggedIn = this.storageService.isLoggedIn();
this.refreshToolbar();
@@ -89,12 +87,14 @@ export class MainComponent implements OnInit{
}
refreshToolbar() {
this.isLoggedIn = this.storageService.isLoggedIn();
if (this.isLoggedIn) {
const user = this.storageService.getUser();
this.roles = user.roles;
this.showAdminBoard = true;//this.roles.includes('ROLE_ADMIN');
this.showAdminBoard = this.roles.includes('ROLE_ADMIN');
this.showModeratorBoard = this.roles.includes('ROLE_MODERATOR');
this.showUserBoard = this.roles.includes('ROLE_USER');
this.username = user.username;
}