]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+signup/+verify-account/verify-account-ask-send-email/verify-account-ask-send-email.component.ts
Update build steps for localization
[github/Chocobozzz/PeerTube.git] / client / src / app / +signup / +verify-account / verify-account-ask-send-email / verify-account-ask-send-email.component.ts
CommitLineData
d9eaee39 1import { Component, OnInit } from '@angular/core'
67ed6552
C
2import { Notifier, RedirectService, ServerService, UserService } from '@app/core'
3import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms'
d9eaee39 4import { I18n } from '@ngx-translate/i18n-polyfill'
ba430d75 5import { ServerConfig } from '@shared/models'
d9eaee39
JM
6
7@Component({
8 selector: 'my-verify-account-ask-send-email',
9 templateUrl: './verify-account-ask-send-email.component.html',
10 styleUrls: [ './verify-account-ask-send-email.component.scss' ]
11})
12
13export class VerifyAccountAskSendEmailComponent extends FormReactive implements OnInit {
ba430d75 14 private serverConfig: ServerConfig
d9eaee39
JM
15
16 constructor (
17 protected formValidatorService: FormValidatorService,
18 private userValidatorsService: UserValidatorsService,
19 private userService: UserService,
20 private serverService: ServerService,
f8b2c1b4 21 private notifier: Notifier,
d9eaee39
JM
22 private redirectService: RedirectService,
23 private i18n: I18n
24 ) {
25 super()
26 }
27
28 get requiresEmailVerification () {
ba430d75 29 return this.serverConfig.signup.requiresEmailVerification
d9eaee39
JM
30 }
31
32 ngOnInit () {
ba430d75
C
33 this.serverConfig = this.serverService.getTmpConfig()
34 this.serverService.getConfig()
35 .subscribe(config => this.serverConfig = config)
36
d9eaee39
JM
37 this.buildForm({
38 'verify-email-email': this.userValidatorsService.USER_EMAIL
39 })
40 }
41
42 askSendVerifyEmail () {
43 const email = this.form.value['verify-email-email']
44 this.userService.askSendVerifyEmail(email)
45 .subscribe(
46 () => {
47 const message = this.i18n(
48 'An email with verification link will be sent to {{email}}.',
49 { email }
50 )
f8b2c1b4 51 this.notifier.success(message)
d9eaee39
JM
52 this.redirectService.redirectToHomepage()
53 },
54
55 err => {
f8b2c1b4 56 this.notifier.error(err.message)
d9eaee39
JM
57 }
58 )
59 }
60}