]>
Commit | Line | Data |
---|---|---|
d9eaee39 | 1 | import { Component, OnInit } from '@angular/core' |
67ed6552 C |
2 | import { Notifier, RedirectService, ServerService, UserService } from '@app/core' |
3 | import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms' | |
d9eaee39 | 4 | import { I18n } from '@ngx-translate/i18n-polyfill' |
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, | |
18 | private userValidatorsService: UserValidatorsService, | |
19 | private userService: UserService, | |
20 | private serverService: ServerService, | |
f8b2c1b4 | 21 | private notifier: Notifier, |
d9eaee39 JM |
22 | private redirectService: RedirectService, |
23 | private i18n: I18n | |
24 | ) { | |
25 | super() | |
26 | } | |
27 | ||
28 | get requiresEmailVerification () { | |
ba430d75 | 29 | return this.serverConfig.signup.requiresEmailVerification |
d9eaee39 JM |
30 | } |
31 | ||
32 | ngOnInit () { | |
ba430d75 C |
33 | this.serverConfig = this.serverService.getTmpConfig() |
34 | this.serverService.getConfig() | |
35 | .subscribe(config => this.serverConfig = config) | |
36 | ||
d9eaee39 JM |
37 | this.buildForm({ |
38 | 'verify-email-email': this.userValidatorsService.USER_EMAIL | |
39 | }) | |
40 | } | |
41 | ||
42 | askSendVerifyEmail () { | |
43 | const email = this.form.value['verify-email-email'] | |
44 | this.userService.askSendVerifyEmail(email) | |
45 | .subscribe( | |
46 | () => { | |
47 | const message = this.i18n( | |
48 | 'An email with verification link will be sent to {{email}}.', | |
49 | { email } | |
50 | ) | |
f8b2c1b4 | 51 | this.notifier.success(message) |
d9eaee39 JM |
52 | this.redirectService.redirectToHomepage() |
53 | }, | |
54 | ||
55 | err => { | |
f8b2c1b4 | 56 | this.notifier.error(err.message) |
d9eaee39 JM |
57 | } |
58 | ) | |
59 | } | |
60 | } |