Refactor tutorial service for public access and enhance authentication handling
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user