aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-12-18 15:31:54 +0100
committerChocobozzz <me@florianbigard.com>2019-12-18 15:40:59 +0100
commitba430d7516bc5b1324b60571ba7594460969b7fb (patch)
treedf5c6952c82f49a94c0a884bbc97d4a0cbd9f867 /client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts
parent5dfb7c1dec8222b0bbccac5b56ad46da1438747e (diff)
downloadPeerTube-ba430d7516bc5b1324b60571ba7594460969b7fb.tar.gz
PeerTube-ba430d7516bc5b1324b60571ba7594460969b7fb.tar.zst
PeerTube-ba430d7516bc5b1324b60571ba7594460969b7fb.zip
Lazy load static objects
Diffstat (limited to 'client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts')
-rw-r--r--client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts43
1 files changed, 22 insertions, 21 deletions
diff --git a/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts b/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts
index ec7cf935c..9d406805f 100644
--- a/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts
+++ b/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts
@@ -6,6 +6,7 @@ import { FormValidatorService } from '@app/shared/forms/form-validators/form-val
6import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service' 6import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service'
7import { User } from '../../../../../../shared' 7import { User } from '../../../../../../shared'
8import { tap } from 'rxjs/operators' 8import { tap } from 'rxjs/operators'
9import { forkJoin } from 'rxjs'
9 10
10@Component({ 11@Component({
11 selector: 'my-account-change-email', 12 selector: 'my-account-change-email',
@@ -45,29 +46,29 @@ export class MyAccountChangeEmailComponent extends FormReactive implements OnIni
45 const password = this.form.value[ 'password' ] 46 const password = this.form.value[ 'password' ]
46 const email = this.form.value[ 'new-email' ] 47 const email = this.form.value[ 'new-email' ]
47 48
48 this.userService.changeEmail(password, email) 49 forkJoin([
49 .pipe( 50 this.serverService.getConfig(),
50 tap(() => this.authService.refreshUserInformation()) 51 this.userService.changeEmail(password, email)
51 ) 52 ]).pipe(tap(() => this.authService.refreshUserInformation()))
52 .subscribe( 53 .subscribe(
53 () => { 54 ([ config ]) => {
54 this.form.reset() 55 this.form.reset()
55 56
56 if (this.serverService.getConfig().signup.requiresEmailVerification) { 57 if (config.signup.requiresEmailVerification) {
57 this.success = this.i18n('Please check your emails to verify your new email.') 58 this.success = this.i18n('Please check your emails to verify your new email.')
58 } else { 59 } else {
59 this.success = this.i18n('Email updated.') 60 this.success = this.i18n('Email updated.')
60 } 61 }
61 }, 62 },
62
63 err => {
64 if (err.status === 401) {
65 this.error = this.i18n('You current password is invalid.')
66 return
67 }
68 63
69 this.error = err.message 64 err => {
65 if (err.status === 401) {
66 this.error = this.i18n('You current password is invalid.')
67 return
70 } 68 }
71 ) 69
70 this.error = err.message
71 }
72 )
72 } 73 }
73} 74}