]>
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' | |
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 | ||
12 | export 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) | |
37 | .subscribe( | |
38 | () => { | |
66357162 | 39 | this.notifier.success($localize`An email with verification link will be sent to ${email}.`) |
d9eaee39 JM |
40 | this.redirectService.redirectToHomepage() |
41 | }, | |
42 | ||
43 | err => { | |
f8b2c1b4 | 44 | this.notifier.error(err.message) |
d9eaee39 JM |
45 | } |
46 | ) | |
47 | } | |
48 | } |