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