1 import { Component, OnInit } from '@angular/core'
2 import { I18n } from '@ngx-translate/i18n-polyfill'
3 import { Notifier, RedirectService } from '@app/core'
4 import { ServerService } from '@app/core/server'
5 import { FormReactive, UserService } from '@app/shared'
6 import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
7 import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service'
8 import { ServerConfig } from '@shared/models'
11 selector: 'my-verify-account-ask-send-email',
12 templateUrl: './verify-account-ask-send-email.component.html',
13 styleUrls: [ './verify-account-ask-send-email.component.scss' ]
16 export class VerifyAccountAskSendEmailComponent extends FormReactive implements OnInit {
17 private serverConfig: ServerConfig
20 protected formValidatorService: FormValidatorService,
21 private userValidatorsService: UserValidatorsService,
22 private userService: UserService,
23 private serverService: ServerService,
24 private notifier: Notifier,
25 private redirectService: RedirectService,
31 get requiresEmailVerification () {
32 return this.serverConfig.signup.requiresEmailVerification
36 this.serverConfig = this.serverService.getTmpConfig()
37 this.serverService.getConfig()
38 .subscribe(config => this.serverConfig = config)
41 'verify-email-email': this.userValidatorsService.USER_EMAIL
45 askSendVerifyEmail () {
46 const email = this.form.value['verify-email-email']
47 this.userService.askSendVerifyEmail(email)
50 const message = this.i18n(
51 'An email with verification link will be sent to {{email}}.',
54 this.notifier.success(message)
55 this.redirectService.redirectToHomepage()
59 this.notifier.error(err.message)