]> 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
Bumped to version v5.2.1
[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'
9589907c 2import { SignupService } from '@app/+signup/shared/signup.service'
d92d070c 3import { Notifier, RedirectService, ServerService } from '@app/core'
7ed1edbb 4import { USER_EMAIL_VALIDATOR } from '@app/shared/form-validators/user-validators'
5c5bcea2 5import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
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 {
2989628b 14 requiresEmailVerification = false
d9eaee39
JM
15
16 constructor (
5c5bcea2 17 protected formReactiveService: FormReactiveService,
9589907c 18 private signupService: SignupService,
d9eaee39 19 private serverService: ServerService,
f8b2c1b4 20 private notifier: Notifier,
66357162 21 private redirectService: RedirectService
2989628b 22 ) {
d9eaee39
JM
23 super()
24 }
25
d9eaee39 26 ngOnInit () {
ba430d75 27 this.serverService.getConfig()
2989628b 28 .subscribe(config => this.requiresEmailVerification = config.signup.requiresEmailVerification)
ba430d75 29
d9eaee39 30 this.buildForm({
7ed1edbb 31 'verify-email-email': USER_EMAIL_VALIDATOR
d9eaee39
JM
32 })
33 }
34
35 askSendVerifyEmail () {
36 const email = this.form.value['verify-email-email']
9589907c 37 this.signupService.askSendVerifyEmail(email)
1378c0d3
C
38 .subscribe({
39 next: () => {
66357162 40 this.notifier.success($localize`An email with verification link will be sent to ${email}.`)
d9eaee39
JM
41 this.redirectService.redirectToHomepage()
42 },
43
1378c0d3
C
44 error: err => this.notifier.error(err.message)
45 })
d9eaee39
JM
46 }
47}