]> 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
Migrate to $localize
[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
C
2import { Notifier, RedirectService, ServerService, UserService } from '@app/core'
3import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms'
ba430d75 4import { ServerConfig } from '@shared/models'
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 {
ba430d75 13 private serverConfig: ServerConfig
d9eaee39
JM
14
15 constructor (
16 protected formValidatorService: FormValidatorService,
17 private userValidatorsService: UserValidatorsService,
18 private userService: UserService,
19 private serverService: ServerService,
f8b2c1b4 20 private notifier: Notifier,
66357162
C
21 private redirectService: RedirectService
22 ) {
d9eaee39
JM
23 super()
24 }
25
26 get requiresEmailVerification () {
ba430d75 27 return this.serverConfig.signup.requiresEmailVerification
d9eaee39
JM
28 }
29
30 ngOnInit () {
ba430d75
C
31 this.serverConfig = this.serverService.getTmpConfig()
32 this.serverService.getConfig()
33 .subscribe(config => this.serverConfig = config)
34
d9eaee39
JM
35 this.buildForm({
36 'verify-email-email': this.userValidatorsService.USER_EMAIL
37 })
38 }
39
40 askSendVerifyEmail () {
41 const email = this.form.value['verify-email-email']
42 this.userService.askSendVerifyEmail(email)
43 .subscribe(
44 () => {
66357162 45 this.notifier.success($localize`An email with verification link will be sent to ${email}.`)
d9eaee39
JM
46 this.redirectService.redirectToHomepage()
47 },
48
49 err => {
f8b2c1b4 50 this.notifier.error(err.message)
d9eaee39
JM
51 }
52 )
53 }
54}