]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - 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
1 import { Component, OnInit } from '@angular/core'
2 import { SignupService } from '@app/+signup/shared/signup.service'
3 import { Notifier, RedirectService, ServerService } from '@app/core'
4 import { USER_EMAIL_VALIDATOR } from '@app/shared/form-validators/user-validators'
5 import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
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
13 export class VerifyAccountAskSendEmailComponent extends FormReactive implements OnInit {
14 requiresEmailVerification = false
15
16 constructor (
17 protected formReactiveService: FormReactiveService,
18 private signupService: SignupService,
19 private serverService: ServerService,
20 private notifier: Notifier,
21 private redirectService: RedirectService
22 ) {
23 super()
24 }
25
26 ngOnInit () {
27 this.serverService.getConfig()
28 .subscribe(config => this.requiresEmailVerification = config.signup.requiresEmailVerification)
29
30 this.buildForm({
31 'verify-email-email': USER_EMAIL_VALIDATOR
32 })
33 }
34
35 askSendVerifyEmail () {
36 const email = this.form.value['verify-email-email']
37 this.signupService.askSendVerifyEmail(email)
38 .subscribe({
39 next: () => {
40 this.notifier.success($localize`An email with verification link will be sent to ${email}.`)
41 this.redirectService.redirectToHomepage()
42 },
43
44 error: err => this.notifier.error(err.message)
45 })
46 }
47 }