]>
Commit | Line | Data |
---|---|---|
d9eaee39 JM |
1 | import { Component, OnInit } from '@angular/core' |
2 | import { I18n } from '@ngx-translate/i18n-polyfill' | |
f8b2c1b4 | 3 | import { Notifier, RedirectService } from '@app/core' |
d9eaee39 | 4 | import { ServerService } from '@app/core/server' |
f8b2c1b4 | 5 | import { FormReactive, UserService } from '@app/shared' |
d9eaee39 JM |
6 | import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' |
7 | import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service' | |
8 | ||
9 | @Component({ | |
10 | selector: 'my-verify-account-ask-send-email', | |
11 | templateUrl: './verify-account-ask-send-email.component.html', | |
12 | styleUrls: [ './verify-account-ask-send-email.component.scss' ] | |
13 | }) | |
14 | ||
15 | export class VerifyAccountAskSendEmailComponent extends FormReactive implements OnInit { | |
16 | ||
17 | constructor ( | |
18 | protected formValidatorService: FormValidatorService, | |
19 | private userValidatorsService: UserValidatorsService, | |
20 | private userService: UserService, | |
21 | private serverService: ServerService, | |
f8b2c1b4 | 22 | private notifier: Notifier, |
d9eaee39 JM |
23 | private redirectService: RedirectService, |
24 | private i18n: I18n | |
25 | ) { | |
26 | super() | |
27 | } | |
28 | ||
29 | get requiresEmailVerification () { | |
30 | return this.serverService.getConfig().signup.requiresEmailVerification | |
31 | } | |
32 | ||
33 | ngOnInit () { | |
34 | this.buildForm({ | |
35 | 'verify-email-email': this.userValidatorsService.USER_EMAIL | |
36 | }) | |
37 | } | |
38 | ||
39 | askSendVerifyEmail () { | |
40 | const email = this.form.value['verify-email-email'] | |
41 | this.userService.askSendVerifyEmail(email) | |
42 | .subscribe( | |
43 | () => { | |
44 | const message = this.i18n( | |
45 | 'An email with verification link will be sent to {{email}}.', | |
46 | { email } | |
47 | ) | |
f8b2c1b4 | 48 | this.notifier.success(message) |
d9eaee39 JM |
49 | this.redirectService.redirectToHomepage() |
50 | }, | |
51 | ||
52 | err => { | |
f8b2c1b4 | 53 | this.notifier.error(err.message) |
d9eaee39 JM |
54 | } |
55 | ) | |
56 | } | |
57 | } |