]> 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
Merge branch 'master' into release/3.3.0
[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 { Notifier, RedirectService, ServerService, UserService } from '@app/core'
3 import { USER_EMAIL_VALIDATOR } from '@app/shared/form-validators/user-validators'
4 import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
5
6 @Component({
7 selector: 'my-verify-account-ask-send-email',
8 templateUrl: './verify-account-ask-send-email.component.html',
9 styleUrls: [ './verify-account-ask-send-email.component.scss' ]
10 })
11
12 export class VerifyAccountAskSendEmailComponent extends FormReactive implements OnInit {
13 requiresEmailVerification = false
14
15 constructor (
16 protected formValidatorService: FormValidatorService,
17 private userService: UserService,
18 private serverService: ServerService,
19 private notifier: Notifier,
20 private redirectService: RedirectService
21 ) {
22 super()
23 }
24
25 ngOnInit () {
26 this.serverService.getConfig()
27 .subscribe(config => this.requiresEmailVerification = config.signup.requiresEmailVerification)
28
29 this.buildForm({
30 'verify-email-email': USER_EMAIL_VALIDATOR
31 })
32 }
33
34 askSendVerifyEmail () {
35 const email = this.form.value['verify-email-email']
36 this.userService.askSendVerifyEmail(email)
37 .subscribe(
38 () => {
39 this.notifier.success($localize`An email with verification link will be sent to ${email}.`)
40 this.redirectService.redirectToHomepage()
41 },
42
43 err => {
44 this.notifier.error(err.message)
45 }
46 )
47 }
48 }