- private friendService: FriendService,
- private route: ActivatedRoute,
- private router: Router
- ) {
- this.isLoggedIn = this.authService.isLoggedIn();
-
- this.authService.loginChangedSource.subscribe(
- status => {
- if (status === AuthStatus.LoggedIn) {
- this.isLoggedIn = true;
- console.log('Logged in.');
- } else if (status === AuthStatus.LoggedOut) {
- this.isLoggedIn = false;
- console.log('Logged out.');
- } else {
- console.error('Unknown auth status: ' + status);
- }
- }
- );
- }
-
- logout() {
- this.authService.logout();
- this.authService.setStatus(AuthStatus.LoggedOut);
- }
-
- makeFriends() {
- this.friendService.makeFriends().subscribe(
- status => {
- if (status === 409) {
- alert('Already made friends!');
- } else {
- alert('Made friends!');
- }
- },
- error => alert(error)
- );
+ 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();
+ }
+
+ this.configService.loadConfig();
+ this.videoService.loadVideoCategories();
+ this.videoService.loadVideoLicences();
+ this.videoService.loadVideoLanguages();