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