From 4771e0008dd26eadbb7eaff64255a6ec914fdadb Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 10 Jul 2017 19:43:21 +0200 Subject: Better typescript typing for a better world --- client/src/app/shared/users/user.service.ts | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'client/src/app/shared/users/user.service.ts') 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' import { AuthService } from '../../core' import { AuthHttp } from '../auth' import { RestExtractor } from '../rest' +import { UserCreate, UserUpdate } from '../../../../../shared' @Injectable() export class UserService { @@ -27,7 +28,7 @@ export class UserService { changePassword (newPassword: string) { const url = UserService.BASE_USERS_URL + this.authService.getUser().id - const body = { + const body: UserUpdate = { password: newPassword } @@ -36,7 +37,7 @@ export class UserService { .catch((res) => this.restExtractor.handleError(res)) } - updateDetails (details: { displayNSFW: boolean }) { + updateDetails (details: UserUpdate) { const url = UserService.BASE_USERS_URL + this.authService.getUser().id return this.authHttp.put(url, details) @@ -44,14 +45,8 @@ export class UserService { .catch((res) => this.restExtractor.handleError(res)) } - signup (username: string, password: string, email: string) { - const body = { - username, - email, - password - } - - return this.http.post(UserService.BASE_USERS_URL + 'register', body) + signup (userCreate: UserCreate) { + return this.http.post(UserService.BASE_USERS_URL + 'register', userCreate) .map(this.restExtractor.extractDataBool) .catch(this.restExtractor.handleError) } -- cgit v1.2.3