diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-03-04 11:45:47 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-03-04 11:45:47 +0100 |
commit | e2a2d6c86c7ca39074fdff3b545947d1d58dc008 (patch) | |
tree | a3420493460f67472acceae2a5746612a30943f0 /client/src/app/account | |
parent | a7449e74f9105839fa03f0b2e23b435f37a1fc2f (diff) | |
download | PeerTube-e2a2d6c86c7ca39074fdff3b545947d1d58dc008.tar.gz PeerTube-e2a2d6c86c7ca39074fdff3b545947d1d58dc008.tar.zst PeerTube-e2a2d6c86c7ca39074fdff3b545947d1d58dc008.zip |
Client: check token valitidy at startup
Diffstat (limited to 'client/src/app/account')
-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/account.service.ts | 28 | ||||
-rw-r--r-- | client/src/app/account/index.ts | 1 |
4 files changed, 4 insertions, 36 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/account.service.ts b/client/src/app/account/account.service.ts deleted file mode 100644 index 046690347..000000000 --- a/client/src/app/account/account.service.ts +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | import { Injectable } from '@angular/core'; | ||
2 | import 'rxjs/add/operator/catch'; | ||
3 | import 'rxjs/add/operator/map'; | ||
4 | |||
5 | import { AuthService } from '../core'; | ||
6 | import { AuthHttp, RestExtractor } from '../shared'; | ||
7 | |||
8 | @Injectable() | ||
9 | export class AccountService { | ||
10 | private static BASE_USERS_URL = '/api/v1/users/'; | ||
11 | |||
12 | constructor( | ||
13 | private authHttp: AuthHttp, | ||
14 | private authService: AuthService, | ||
15 | private restExtractor: RestExtractor | ||
16 | ) {} | ||
17 | |||
18 | changePassword(newPassword: string) { | ||
19 | const url = AccountService.BASE_USERS_URL + this.authService.getUser().id; | ||
20 | const body = { | ||
21 | password: newPassword | ||
22 | }; | ||
23 | |||
24 | return this.authHttp.put(url, body) | ||
25 | .map(this.restExtractor.extractDataBool) | ||
26 | .catch((res) => this.restExtractor.handleError(res)); | ||
27 | } | ||
28 | } | ||
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'; | ||