aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/users
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-07-10 19:43:21 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-07-10 19:43:21 +0200
commit4771e0008dd26eadbb7eaff64255a6ec914fdadb (patch)
tree4fd58f8a3f3c2d674b936c99817b4f5fb958c5d8 /client/src/app/shared/users
parent7a214f746bf420defbf17fa218d90d6233551bf8 (diff)
downloadPeerTube-4771e0008dd26eadbb7eaff64255a6ec914fdadb.tar.gz
PeerTube-4771e0008dd26eadbb7eaff64255a6ec914fdadb.tar.zst
PeerTube-4771e0008dd26eadbb7eaff64255a6ec914fdadb.zip
Better typescript typing for a better world
Diffstat (limited to 'client/src/app/shared/users')
-rw-r--r--client/src/app/shared/users/user.service.ts15
1 files changed, 5 insertions, 10 deletions
diff --git a/client/src/app/shared/users/user.service.ts b/client/src/app/shared/users/user.service.ts
index e956df5b1..b479ac034 100644
--- a/client/src/app/shared/users/user.service.ts
+++ b/client/src/app/shared/users/user.service.ts
@@ -6,6 +6,7 @@ import 'rxjs/add/operator/map'
6import { AuthService } from '../../core' 6import { AuthService } from '../../core'
7import { AuthHttp } from '../auth' 7import { AuthHttp } from '../auth'
8import { RestExtractor } from '../rest' 8import { RestExtractor } from '../rest'
9import { UserCreate, UserUpdate } from '../../../../../shared'
9 10
10@Injectable() 11@Injectable()
11export class UserService { 12export class UserService {
@@ -27,7 +28,7 @@ export class UserService {
27 28
28 changePassword (newPassword: string) { 29 changePassword (newPassword: string) {
29 const url = UserService.BASE_USERS_URL + this.authService.getUser().id 30 const url = UserService.BASE_USERS_URL + this.authService.getUser().id
30 const body = { 31 const body: UserUpdate = {
31 password: newPassword 32 password: newPassword
32 } 33 }
33 34
@@ -36,7 +37,7 @@ export class UserService {
36 .catch((res) => this.restExtractor.handleError(res)) 37 .catch((res) => this.restExtractor.handleError(res))
37 } 38 }
38 39
39 updateDetails (details: { displayNSFW: boolean }) { 40 updateDetails (details: UserUpdate) {
40 const url = UserService.BASE_USERS_URL + this.authService.getUser().id 41 const url = UserService.BASE_USERS_URL + this.authService.getUser().id
41 42
42 return this.authHttp.put(url, details) 43 return this.authHttp.put(url, details)
@@ -44,14 +45,8 @@ export class UserService {
44 .catch((res) => this.restExtractor.handleError(res)) 45 .catch((res) => this.restExtractor.handleError(res))
45 } 46 }
46 47
47 signup (username: string, password: string, email: string) { 48 signup (userCreate: UserCreate) {
48 const body = { 49 return this.http.post(UserService.BASE_USERS_URL + 'register', userCreate)
49 username,
50 email,
51 password
52 }
53
54 return this.http.post(UserService.BASE_USERS_URL + 'register', body)
55 .map(this.restExtractor.extractDataBool) 50 .map(this.restExtractor.extractDataBool)
56 .catch(this.restExtractor.handleError) 51 .catch(this.restExtractor.handleError)
57 } 52 }