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