1
|
import { Router } from '@angular/router';
|
2
|
import { AuthService } from 'src/app/shared/services/auth.service';
|
3
|
import { Component, OnInit } from '@angular/core';
|
4
|
|
5
|
@Component({
|
6
|
selector: 'app-main-page',
|
7
|
templateUrl: './main-page.component.html',
|
8
|
styleUrls: ['./main-page.component.scss']
|
9
|
})
|
10
|
export class MainPageComponent implements OnInit {
|
11
|
|
12
|
constructor(private auth: AuthService, private router: Router) { }
|
13
|
|
14
|
ngOnInit(): void {
|
15
|
this.auth.authStatusChanged.subscribe((isAuthenticated) => {
|
16
|
if (!isAuthenticated) {
|
17
|
this.router.navigateByUrl('login');
|
18
|
}
|
19
|
});
|
20
|
}
|
21
|
|
22
|
}
|