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