1 import { Component, OnInit } from '@angular/core'
2 import { I18n } from '@ngx-translate/i18n-polyfill'
3 import { NotificationsService } from 'angular2-notifications'
4 import { ServerService } from '@app/core/server'
5 import { RedirectService } from '@app/core'
6 import { UserService, FormReactive } from '@app/shared'
7 import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
8 import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service'
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 {
19 protected formValidatorService: FormValidatorService,
20 private userValidatorsService: UserValidatorsService,
21 private userService: UserService,
22 private serverService: ServerService,
23 private notificationsService: NotificationsService,
24 private redirectService: RedirectService,
30 get requiresEmailVerification () {
31 return this.serverService.getConfig().signup.requiresEmailVerification
36 'verify-email-email': this.userValidatorsService.USER_EMAIL
40 askSendVerifyEmail () {
41 const email = this.form.value['verify-email-email']
42 this.userService.askSendVerifyEmail(email)
45 const message = this.i18n(
46 'An email with verification link will be sent to {{email}}.',
49 this.notificationsService.success(this.i18n('Success'), message)
50 this.redirectService.redirectToHomepage()
54 this.notificationsService.error(this.i18n('Error'), err.message)