]>
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' | |
ba430d75 | 8 | import { ServerConfig } from '@shared/models' |
d9eaee39 JM |
9 | |
10 | @Component({ | |
11 | selector: 'my-verify-account-ask-send-email', | |
12 | templateUrl: './verify-account-ask-send-email.component.html', | |
13 | styleUrls: [ './verify-account-ask-send-email.component.scss' ] | |
14 | }) | |
15 | ||
16 | export class VerifyAccountAskSendEmailComponent extends FormReactive implements OnInit { | |
ba430d75 | 17 | private serverConfig: ServerConfig |
d9eaee39 JM |
18 | |
19 | constructor ( | |
20 | protected formValidatorService: FormValidatorService, | |
21 | private userValidatorsService: UserValidatorsService, | |
22 | private userService: UserService, | |
23 | private serverService: ServerService, | |
f8b2c1b4 | 24 | private notifier: Notifier, |
d9eaee39 JM |
25 | private redirectService: RedirectService, |
26 | private i18n: I18n | |
27 | ) { | |
28 | super() | |
29 | } | |
30 | ||
31 | get requiresEmailVerification () { | |
ba430d75 | 32 | return this.serverConfig.signup.requiresEmailVerification |
d9eaee39 JM |
33 | } |
34 | ||
35 | ngOnInit () { | |
ba430d75 C |
36 | this.serverConfig = this.serverService.getTmpConfig() |
37 | this.serverService.getConfig() | |
38 | .subscribe(config => this.serverConfig = config) | |
39 | ||
d9eaee39 JM |
40 | this.buildForm({ |
41 | 'verify-email-email': this.userValidatorsService.USER_EMAIL | |
42 | }) | |
43 | } | |
44 | ||
45 | askSendVerifyEmail () { | |
46 | const email = this.form.value['verify-email-email'] | |
47 | this.userService.askSendVerifyEmail(email) | |
48 | .subscribe( | |
49 | () => { | |
50 | const message = this.i18n( | |
51 | 'An email with verification link will be sent to {{email}}.', | |
52 | { email } | |
53 | ) | |
f8b2c1b4 | 54 | this.notifier.success(message) |
d9eaee39 JM |
55 | this.redirectService.redirectToHomepage() |
56 | }, | |
57 | ||
58 | err => { | |
f8b2c1b4 | 59 | this.notifier.error(err.message) |
d9eaee39 JM |
60 | } |
61 | ) | |
62 | } | |
63 | } |