diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/src/app/account/account.component.ts | 7 | ||||
-rw-r--r-- | client/src/app/account/account.module.ts | 4 | ||||
-rw-r--r-- | client/src/app/account/index.ts | 1 | ||||
-rw-r--r-- | client/src/app/app.component.ts | 18 | ||||
-rw-r--r-- | client/src/app/core/auth/auth-status.model.ts (renamed from client/src/app/shared/auth/auth-status.model.ts) | 0 | ||||
-rw-r--r-- | client/src/app/core/auth/auth-user.model.ts (renamed from client/src/app/shared/auth/auth-user.model.ts) | 3 | ||||
-rw-r--r-- | client/src/app/core/auth/auth.service.ts | 4 | ||||
-rw-r--r-- | client/src/app/core/auth/index.ts | 2 | ||||
-rw-r--r-- | client/src/app/core/menu/menu.component.ts | 3 | ||||
-rw-r--r-- | client/src/app/shared/auth/index.ts | 2 | ||||
-rw-r--r-- | client/src/app/shared/shared.module.ts | 4 | ||||
-rw-r--r-- | client/src/app/shared/users/index.ts | 1 | ||||
-rw-r--r-- | client/src/app/shared/users/user.service.ts (renamed from client/src/app/account/account.service.ts) | 16 | ||||
-rw-r--r-- | client/src/app/videos/video-list/video-list.component.ts | 4 |
14 files changed, 44 insertions, 25 deletions
diff --git a/client/src/app/account/account.component.ts b/client/src/app/account/account.component.ts index 9b6b5fbf4..14452a73e 100644 --- a/client/src/app/account/account.component.ts +++ b/client/src/app/account/account.component.ts | |||
@@ -4,8 +4,7 @@ import { Router } from '@angular/router'; | |||
4 | 4 | ||
5 | import { NotificationsService } from 'angular2-notifications'; | 5 | import { NotificationsService } from 'angular2-notifications'; |
6 | 6 | ||
7 | import { AccountService } from './account.service'; | 7 | import { FormReactive, UserService, USER_PASSWORD } from '../shared'; |
8 | import { FormReactive, USER_PASSWORD } from '../shared'; | ||
9 | 8 | ||
10 | @Component({ | 9 | @Component({ |
11 | selector: 'my-account', | 10 | selector: 'my-account', |
@@ -29,7 +28,7 @@ export class AccountComponent extends FormReactive implements OnInit { | |||
29 | private formBuilder: FormBuilder, | 28 | private formBuilder: FormBuilder, |
30 | private router: Router, | 29 | private router: Router, |
31 | private notificationsService: NotificationsService, | 30 | private notificationsService: NotificationsService, |
32 | private accountService: AccountService | 31 | private userService: UserService |
33 | ) { | 32 | ) { |
34 | super(); | 33 | super(); |
35 | } | 34 | } |
@@ -58,7 +57,7 @@ export class AccountComponent extends FormReactive implements OnInit { | |||
58 | return; | 57 | return; |
59 | } | 58 | } |
60 | 59 | ||
61 | this.accountService.changePassword(newPassword).subscribe( | 60 | this.userService.changePassword(newPassword).subscribe( |
62 | () => this.notificationsService.success('Success', 'Password updated.'), | 61 | () => this.notificationsService.success('Success', 'Password updated.'), |
63 | 62 | ||
64 | err => this.error = err | 63 | err => this.error = err |
diff --git a/client/src/app/account/account.module.ts b/client/src/app/account/account.module.ts index 53f6ba58e..75f2ee6f9 100644 --- a/client/src/app/account/account.module.ts +++ b/client/src/app/account/account.module.ts | |||
@@ -19,8 +19,6 @@ import { SharedModule } from '../shared'; | |||
19 | AccountComponent | 19 | AccountComponent |
20 | ], | 20 | ], |
21 | 21 | ||
22 | providers: [ | 22 | providers: [] |
23 | AccountService | ||
24 | ] | ||
25 | }) | 23 | }) |
26 | export class AccountModule { } | 24 | export class AccountModule { } |
diff --git a/client/src/app/account/index.ts b/client/src/app/account/index.ts index be03713cb..9265fa10a 100644 --- a/client/src/app/account/index.ts +++ b/client/src/app/account/index.ts | |||
@@ -1,4 +1,3 @@ | |||
1 | export * from './account-routing.module'; | 1 | export * from './account-routing.module'; |
2 | export * from './account.component'; | 2 | export * from './account.component'; |
3 | export * from './account.module'; | 3 | export * from './account.module'; |
4 | export * from './account.service'; | ||
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 @@ | |||
1 | import { Component, ViewContainerRef } from '@angular/core'; | 1 | import { Component, OnInit, ViewContainerRef } from '@angular/core'; |
2 | import { Router } from '@angular/router'; | 2 | import { Router } from '@angular/router'; |
3 | 3 | ||
4 | import { MetaService } from 'ng2-meta'; | 4 | import { MetaService } from 'ng2-meta'; |
5 | |||
6 | import { AuthService } from './core'; | ||
7 | import { 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 | 14 | export class AppComponent implements OnInit { | |
11 | export 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 | } |
diff --git a/client/src/app/shared/auth/auth-status.model.ts b/client/src/app/core/auth/auth-status.model.ts index f646bd4cf..f646bd4cf 100644 --- a/client/src/app/shared/auth/auth-status.model.ts +++ b/client/src/app/core/auth/auth-status.model.ts | |||
diff --git a/client/src/app/shared/auth/auth-user.model.ts b/client/src/app/core/auth/auth-user.model.ts index f560351f4..5d61954d6 100644 --- a/client/src/app/shared/auth/auth-user.model.ts +++ b/client/src/app/core/auth/auth-user.model.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | import { User } from '../users'; | 1 | // Do not use the barrel (dependency loop) |
2 | import { User } from '../../shared/users/user.model'; | ||
2 | 3 | ||
3 | export class AuthUser extends User { | 4 | export class AuthUser extends User { |
4 | private static KEYS = { | 5 | private static KEYS = { |
diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts index a56adbbad..2e7328197 100644 --- a/client/src/app/core/auth/auth.service.ts +++ b/client/src/app/core/auth/auth.service.ts | |||
@@ -9,9 +9,9 @@ import 'rxjs/add/observable/throw'; | |||
9 | 9 | ||
10 | import { NotificationsService } from 'angular2-notifications'; | 10 | import { NotificationsService } from 'angular2-notifications'; |
11 | 11 | ||
12 | import { AuthStatus } from './auth-status.model'; | ||
13 | import { AuthUser } from './auth-user.model'; | ||
12 | // Do not use the barrel (dependency loop) | 14 | // Do not use the barrel (dependency loop) |
13 | import { AuthStatus } from '../../shared/auth/auth-status.model'; | ||
14 | import { AuthUser } from '../../shared/auth/auth-user.model'; | ||
15 | import { RestExtractor } from '../../shared/rest'; | 15 | import { RestExtractor } from '../../shared/rest'; |
16 | 16 | ||
17 | @Injectable() | 17 | @Injectable() |
diff --git a/client/src/app/core/auth/index.ts b/client/src/app/core/auth/index.ts index cf52c9c7c..67a18cfbb 100644 --- a/client/src/app/core/auth/index.ts +++ b/client/src/app/core/auth/index.ts | |||
@@ -1 +1,3 @@ | |||
1 | export * from './auth-status.model'; | ||
2 | export * from './auth-user.model'; | ||
1 | export * from './auth.service' | 3 | export * from './auth.service' |
diff --git a/client/src/app/core/menu/menu.component.ts b/client/src/app/core/menu/menu.component.ts index f1bf6966d..5ca60e5e0 100644 --- a/client/src/app/core/menu/menu.component.ts +++ b/client/src/app/core/menu/menu.component.ts | |||
@@ -1,8 +1,7 @@ | |||
1 | import { Component, OnInit } from '@angular/core'; | 1 | import { Component, OnInit } from '@angular/core'; |
2 | import { Router } from '@angular/router'; | 2 | import { Router } from '@angular/router'; |
3 | 3 | ||
4 | import { AuthService } from '../auth'; | 4 | import { AuthService, AuthStatus } from '../auth'; |
5 | import { AuthStatus } from '../../shared'; | ||
6 | 5 | ||
7 | @Component({ | 6 | @Component({ |
8 | selector: 'my-menu', | 7 | selector: 'my-menu', |
diff --git a/client/src/app/shared/auth/index.ts b/client/src/app/shared/auth/index.ts index ce0bd8adf..c488aed69 100644 --- a/client/src/app/shared/auth/index.ts +++ b/client/src/app/shared/auth/index.ts | |||
@@ -1,3 +1 @@ | |||
1 | export * from './auth-http.service'; | export * from './auth-http.service'; | |
2 | export * from './auth-status.model'; | ||
3 | export * from './auth-user.model'; | ||
diff --git a/client/src/app/shared/shared.module.ts b/client/src/app/shared/shared.module.ts index 0f57ef078..84cc86c64 100644 --- a/client/src/app/shared/shared.module.ts +++ b/client/src/app/shared/shared.module.ts | |||
@@ -16,6 +16,7 @@ import { Ng2SmartTableModule } from 'ng2-smart-table'; | |||
16 | import { AUTH_HTTP_PROVIDERS } from './auth'; | 16 | import { AUTH_HTTP_PROVIDERS } from './auth'; |
17 | import { RestExtractor, RestService } from './rest'; | 17 | import { RestExtractor, RestService } from './rest'; |
18 | import { SearchComponent, SearchService } from './search'; | 18 | import { SearchComponent, SearchService } from './search'; |
19 | import { UserService } from './users'; | ||
19 | import { VideoAbuseService } from './video-abuse'; | 20 | import { VideoAbuseService } from './video-abuse'; |
20 | 21 | ||
21 | @NgModule({ | 22 | @NgModule({ |
@@ -65,7 +66,8 @@ import { VideoAbuseService } from './video-abuse'; | |||
65 | RestExtractor, | 66 | RestExtractor, |
66 | RestService, | 67 | RestService, |
67 | SearchService, | 68 | SearchService, |
68 | VideoAbuseService | 69 | VideoAbuseService, |
70 | UserService | ||
69 | ] | 71 | ] |
70 | }) | 72 | }) |
71 | export class SharedModule { } | 73 | export class SharedModule { } |
diff --git a/client/src/app/shared/users/index.ts b/client/src/app/shared/users/index.ts index 5a670ce8f..ff009e89b 100644 --- a/client/src/app/shared/users/index.ts +++ b/client/src/app/shared/users/index.ts | |||
@@ -1 +1,2 @@ | |||
1 | export * from './user.model'; | 1 | export * from './user.model'; |
2 | export * from './user.service'; | ||
diff --git a/client/src/app/account/account.service.ts b/client/src/app/shared/users/user.service.ts index 046690347..4cf100f0d 100644 --- a/client/src/app/account/account.service.ts +++ b/client/src/app/shared/users/user.service.ts | |||
@@ -2,11 +2,12 @@ import { Injectable } from '@angular/core'; | |||
2 | import 'rxjs/add/operator/catch'; | 2 | import 'rxjs/add/operator/catch'; |
3 | import 'rxjs/add/operator/map'; | 3 | import 'rxjs/add/operator/map'; |
4 | 4 | ||
5 | import { AuthService } from '../core'; | 5 | import { AuthService } from '../../core'; |
6 | import { AuthHttp, RestExtractor } from '../shared'; | 6 | import { AuthHttp } from '../auth'; |
7 | import { RestExtractor } from '../rest'; | ||
7 | 8 | ||
8 | @Injectable() | 9 | @Injectable() |
9 | export class AccountService { | 10 | export class UserService { |
10 | private static BASE_USERS_URL = '/api/v1/users/'; | 11 | private static BASE_USERS_URL = '/api/v1/users/'; |
11 | 12 | ||
12 | constructor( | 13 | constructor( |
@@ -15,8 +16,15 @@ export class AccountService { | |||
15 | private restExtractor: RestExtractor | 16 | private restExtractor: RestExtractor |
16 | ) {} | 17 | ) {} |
17 | 18 | ||
19 | checkTokenValidity() { | ||
20 | const url = UserService.BASE_USERS_URL + 'me'; | ||
21 | |||
22 | // AuthHttp will redirect us to the login page if the oken is not valid anymore | ||
23 | this.authHttp.get(url).subscribe(() => { ; }); | ||
24 | } | ||
25 | |||
18 | changePassword(newPassword: string) { | 26 | changePassword(newPassword: string) { |
19 | const url = AccountService.BASE_USERS_URL + this.authService.getUser().id; | 27 | const url = UserService.BASE_USERS_URL + this.authService.getUser().id; |
20 | const body = { | 28 | const body = { |
21 | password: newPassword | 29 | password: newPassword |
22 | }; | 30 | }; |
diff --git a/client/src/app/videos/video-list/video-list.component.ts b/client/src/app/videos/video-list/video-list.component.ts index b3780f8b6..844e14567 100644 --- a/client/src/app/videos/video-list/video-list.component.ts +++ b/client/src/app/videos/video-list/video-list.component.ts | |||
@@ -9,8 +9,8 @@ import { | |||
9 | Video, | 9 | Video, |
10 | VideoService | 10 | VideoService |
11 | } from '../shared'; | 11 | } from '../shared'; |
12 | import { AuthService } from '../../core'; | 12 | import { AuthService, AuthUser } from '../../core'; |
13 | import { AuthUser, RestPagination, Search, SearchField } from '../../shared'; | 13 | import { RestPagination, Search, SearchField } from '../../shared'; |
14 | import { SearchService } from '../../shared'; | 14 | import { SearchService } from '../../shared'; |
15 | 15 | ||
16 | @Component({ | 16 | @Component({ |