]>
Commit | Line | Data |
---|---|---|
d9eaee39 | 1 | import { Component, OnInit } from '@angular/core' |
67ed6552 | 2 | import { Notifier, RedirectService, ServerService, UserService } from '@app/core' |
7ed1edbb C |
3 | import { USER_EMAIL_VALIDATOR } from '@app/shared/form-validators/user-validators' |
4 | import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' | |
ba430d75 | 5 | import { ServerConfig } from '@shared/models' |
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 | ||
13 | export class VerifyAccountAskSendEmailComponent extends FormReactive implements OnInit { | |
ba430d75 | 14 | private serverConfig: ServerConfig |
d9eaee39 JM |
15 | |
16 | constructor ( | |
17 | protected formValidatorService: FormValidatorService, | |
d9eaee39 JM |
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 | 35 | this.buildForm({ |
7ed1edbb | 36 | 'verify-email-email': USER_EMAIL_VALIDATOR |
d9eaee39 JM |
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 | } |