import { Component, OnInit } from '@angular/core'
-import { I18n } from '@ngx-translate/i18n-polyfill'
-import { Notifier, RedirectService } from '@app/core'
-import { ServerService } from '@app/core/server'
-import { FormReactive, UserService } from '@app/shared'
-import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
-import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service'
+import { Notifier, RedirectService, ServerService } from '@app/core'
+import { USER_EMAIL_VALIDATOR } from '@app/shared/form-validators/user-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
+import { UserSignupService } from '@app/shared/shared-users'
@Component({
selector: 'my-verify-account-ask-send-email',
})
export class VerifyAccountAskSendEmailComponent extends FormReactive implements OnInit {
+ requiresEmailVerification = false
constructor (
protected formValidatorService: FormValidatorService,
- private userValidatorsService: UserValidatorsService,
- private userService: UserService,
+ private userSignupService: UserSignupService,
private serverService: ServerService,
private notifier: Notifier,
- private redirectService: RedirectService,
- private i18n: I18n
+ private redirectService: RedirectService
) {
super()
}
- get requiresEmailVerification () {
- return this.serverService.getConfig().signup.requiresEmailVerification
- }
-
ngOnInit () {
+ this.serverService.getConfig()
+ .subscribe(config => this.requiresEmailVerification = config.signup.requiresEmailVerification)
+
this.buildForm({
- 'verify-email-email': this.userValidatorsService.USER_EMAIL
+ 'verify-email-email': USER_EMAIL_VALIDATOR
})
}
askSendVerifyEmail () {
const email = this.form.value['verify-email-email']
- this.userService.askSendVerifyEmail(email)
- .subscribe(
- () => {
- const message = this.i18n(
- 'An email with verification link will be sent to {{email}}.',
- { email }
- )
- this.notifier.success(message)
+ this.userSignupService.askSendVerifyEmail(email)
+ .subscribe({
+ next: () => {
+ this.notifier.success($localize`An email with verification link will be sent to ${email}.`)
this.redirectService.redirectToHomepage()
},
- err => {
- this.notifier.error(err.message)
- }
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}