From 0ba5f5baade94a051710d9d9d408ac8083c14ac6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 11 Jun 2019 14:30:49 +0200 Subject: Add ability to change email in client --- client/src/app/shared/users/user.model.ts | 1 + client/src/app/shared/users/user.service.ts | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'client/src/app/shared/users') diff --git a/client/src/app/shared/users/user.model.ts b/client/src/app/shared/users/user.model.ts index e3ed2dfbd..14d13959a 100644 --- a/client/src/app/shared/users/user.model.ts +++ b/client/src/app/shared/users/user.model.ts @@ -8,6 +8,7 @@ export class User implements UserServerModel { id: number username: string email: string + pendingEmail: string | null emailVerified: boolean nsfwPolicy: NSFWPolicyType diff --git a/client/src/app/shared/users/user.service.ts b/client/src/app/shared/users/user.service.ts index 70ff9a058..41ee87197 100644 --- a/client/src/app/shared/users/user.service.ts +++ b/client/src/app/shared/users/user.service.ts @@ -38,6 +38,20 @@ export class UserService { ) } + changeEmail (password: string, newEmail: string) { + const url = UserService.BASE_USERS_URL + 'me' + const body: UserUpdateMe = { + currentPassword: password, + email: newEmail + } + + return this.authHttp.put(url, body) + .pipe( + map(this.restExtractor.extractDataBool), + catchError(err => this.restExtractor.handleError(err)) + ) + } + updateMyProfile (profile: UserUpdateMe) { const url = UserService.BASE_USERS_URL + 'me' @@ -104,10 +118,11 @@ export class UserService { ) } - verifyEmail (userId: number, verificationString: string) { + verifyEmail (userId: number, verificationString: string, isPendingEmail: boolean) { const url = `${UserService.BASE_USERS_URL}/${userId}/verify-email` const body = { - verificationString + verificationString, + isPendingEmail } return this.authHttp.post(url, body) -- cgit v1.2.3