aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/app.component.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-03-04 11:45:47 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-03-04 11:45:47 +0100
commite2a2d6c86c7ca39074fdff3b545947d1d58dc008 (patch)
treea3420493460f67472acceae2a5746612a30943f0 /client/src/app/app.component.ts
parenta7449e74f9105839fa03f0b2e23b435f37a1fc2f (diff)
downloadPeerTube-e2a2d6c86c7ca39074fdff3b545947d1d58dc008.tar.gz
PeerTube-e2a2d6c86c7ca39074fdff3b545947d1d58dc008.tar.zst
PeerTube-e2a2d6c86c7ca39074fdff3b545947d1d58dc008.zip
Client: check token valitidy at startup
Diffstat (limited to 'client/src/app/app.component.ts')
-rw-r--r--client/src/app/app.component.ts18
1 files changed, 15 insertions, 3 deletions
diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts
index f487e6c48..47d2bfdd2 100644
--- a/client/src/app/app.component.ts
+++ b/client/src/app/app.component.ts
@@ -1,14 +1,17 @@
1import { Component, ViewContainerRef } from '@angular/core'; 1import { Component, OnInit, ViewContainerRef } from '@angular/core';
2import { Router } from '@angular/router'; 2import { Router } from '@angular/router';
3 3
4import { MetaService } from 'ng2-meta'; 4import { MetaService } from 'ng2-meta';
5
6import { AuthService } from './core';
7import { UserService } from './shared';
8
5@Component({ 9@Component({
6 selector: 'my-app', 10 selector: 'my-app',
7 templateUrl: './app.component.html', 11 templateUrl: './app.component.html',
8 styleUrls: [ './app.component.scss' ] 12 styleUrls: [ './app.component.scss' ]
9}) 13})
10 14export class AppComponent implements OnInit {
11export class AppComponent {
12 notificationOptions = { 15 notificationOptions = {
13 timeOut: 3000, 16 timeOut: 3000,
14 lastOnBottom: true, 17 lastOnBottom: true,
@@ -25,9 +28,18 @@ export class AppComponent {
25 constructor( 28 constructor(
26 private router: Router, 29 private router: Router,
27 private metaService: MetaService, 30 private metaService: MetaService,
31 private authService: AuthService,
32 private userService: UserService,
28 viewContainerRef: ViewContainerRef 33 viewContainerRef: ViewContainerRef
29 ) {} 34 ) {}
30 35
36 ngOnInit() {
37 if (this.authService.isLoggedIn()) {
38 // The service will automatically redirect to the login page if the token is not valid anymore
39 this.userService.checkTokenValidity();
40 }
41 }
42
31 isInAdmin() { 43 isInAdmin() {
32 return this.router.url.indexOf('/admin/') !== -1; 44 return this.router.url.indexOf('/admin/') !== -1;
33 } 45 }