- private friendService: FriendService,
- private router: Router
- ) {
- this.isLoggedIn = this.authService.isLoggedIn();
-
- this.authService.loginChangedSource.subscribe(
- status => {
- if (status === AuthStatus.LoggedIn) {
- this.isLoggedIn = true;
- }
- }
- );
- }
-
- onSearch(search: Search) {
- if (search.value !== '') {
- const params = {
- field: search.field,
- search: search.value
- };
- this.router.navigate(['/videos/list', params]);
- } else {
- this.router.navigate(['/videos/list']);
+ private configService: ConfigService,
+ private userService: UserService,
+ private videoService: VideoService,
+ viewContainerRef: ViewContainerRef
+ ) {}
+
+ ngOnInit() {
+ if (this.authService.isLoggedIn()) {
+ // The service will automatically redirect to the login page if the token is not valid anymore
+ this.userService.checkTokenValidity();