import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service'
import { User } from '../../../../../../shared'
import { tap } from 'rxjs/operators'
+import { forkJoin } from 'rxjs'
@Component({
selector: 'my-account-change-email',
const password = this.form.value[ 'password' ]
const email = this.form.value[ 'new-email' ]
- this.userService.changeEmail(password, email)
- .pipe(
- tap(() => this.authService.refreshUserInformation())
- )
- .subscribe(
- () => {
- this.form.reset()
+ forkJoin([
+ this.serverService.getConfig(),
+ this.userService.changeEmail(password, email)
+ ]).pipe(tap(() => this.authService.refreshUserInformation()))
+ .subscribe(
+ ([ config ]) => {
+ this.form.reset()
- if (this.serverService.getConfig().signup.requiresEmailVerification) {
- this.success = this.i18n('Please check your emails to verify your new email.')
- } else {
- this.success = this.i18n('Email updated.')
- }
- },
-
- err => {
- if (err.status === 401) {
- this.error = this.i18n('You current password is invalid.')
- return
- }
+ if (config.signup.requiresEmailVerification) {
+ this.success = this.i18n('Please check your emails to verify your new email.')
+ } else {
+ this.success = this.i18n('Email updated.')
+ }
+ },
- this.error = err.message
+ err => {
+ if (err.status === 401) {
+ this.error = this.i18n('You current password is invalid.')
+ return
}
- )
+
+ this.error = err.message
+ }
+ )
}
}