diff options
Diffstat (limited to 'client/src/app/signup/signup.component.ts')
-rw-r--r-- | client/src/app/signup/signup.component.ts | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/client/src/app/signup/signup.component.ts b/client/src/app/signup/signup.component.ts deleted file mode 100644 index 13941ec79..000000000 --- a/client/src/app/signup/signup.component.ts +++ /dev/null | |||
@@ -1,78 +0,0 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | ||
2 | import { AuthService, Notifier, RedirectService, ServerService } from '@app/core' | ||
3 | import { UserCreate } from '../../../../shared' | ||
4 | import { FormReactive, UserService, UserValidatorsService } from '../shared' | ||
5 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
6 | import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' | ||
7 | |||
8 | @Component({ | ||
9 | selector: 'my-signup', | ||
10 | templateUrl: './signup.component.html', | ||
11 | styleUrls: [ './signup.component.scss' ] | ||
12 | }) | ||
13 | export class SignupComponent extends FormReactive implements OnInit { | ||
14 | info: string = null | ||
15 | error: string = null | ||
16 | signupDone = false | ||
17 | |||
18 | constructor ( | ||
19 | protected formValidatorService: FormValidatorService, | ||
20 | private authService: AuthService, | ||
21 | private userValidatorsService: UserValidatorsService, | ||
22 | private notifier: Notifier, | ||
23 | private userService: UserService, | ||
24 | private serverService: ServerService, | ||
25 | private redirectService: RedirectService, | ||
26 | private i18n: I18n | ||
27 | ) { | ||
28 | super() | ||
29 | } | ||
30 | |||
31 | get instanceHost () { | ||
32 | return window.location.host | ||
33 | } | ||
34 | |||
35 | get requiresEmailVerification () { | ||
36 | return this.serverService.getConfig().signup.requiresEmailVerification | ||
37 | } | ||
38 | |||
39 | ngOnInit () { | ||
40 | this.buildForm({ | ||
41 | username: this.userValidatorsService.USER_USERNAME, | ||
42 | password: this.userValidatorsService.USER_PASSWORD, | ||
43 | email: this.userValidatorsService.USER_EMAIL, | ||
44 | terms: this.userValidatorsService.USER_TERMS | ||
45 | }) | ||
46 | } | ||
47 | |||
48 | signup () { | ||
49 | this.error = null | ||
50 | |||
51 | const userCreate: UserCreate = this.form.value | ||
52 | |||
53 | this.userService.signup(userCreate).subscribe( | ||
54 | () => { | ||
55 | this.signupDone = true | ||
56 | |||
57 | if (this.requiresEmailVerification) { | ||
58 | this.info = this.i18n('Welcome! Now please check your emails to verify your account and complete signup.') | ||
59 | return | ||
60 | } | ||
61 | |||
62 | // Auto login | ||
63 | this.authService.login(userCreate.username, userCreate.password) | ||
64 | .subscribe( | ||
65 | () => { | ||
66 | this.notifier.success(this.i18n('You are now logged in as {{username}}!', { username: userCreate.username })) | ||
67 | |||
68 | this.redirectService.redirectToHomepage() | ||
69 | }, | ||
70 | |||
71 | err => this.error = err.message | ||
72 | ) | ||
73 | }, | ||
74 | |||
75 | err => this.error = err.message | ||
76 | ) | ||
77 | } | ||
78 | } | ||