diff options
Diffstat (limited to 'client/src/app/signup/signup.component.ts')
-rw-r--r-- | client/src/app/signup/signup.component.ts | 89 |
1 files changed, 0 insertions, 89 deletions
diff --git a/client/src/app/signup/signup.component.ts b/client/src/app/signup/signup.component.ts deleted file mode 100644 index 11eaa8521..000000000 --- a/client/src/app/signup/signup.component.ts +++ /dev/null | |||
@@ -1,89 +0,0 @@ | |||
1 | import { Component } from '@angular/core' | ||
2 | import { AuthService, Notifier, RedirectService, ServerService } from '@app/core' | ||
3 | import { UserService, UserValidatorsService } from '../shared' | ||
4 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
5 | import { UserRegister } from '@shared/models/users/user-register.model' | ||
6 | import { FormGroup } from '@angular/forms' | ||
7 | |||
8 | @Component({ | ||
9 | selector: 'my-signup', | ||
10 | templateUrl: './signup.component.html', | ||
11 | styleUrls: [ './signup.component.scss' ] | ||
12 | }) | ||
13 | export class SignupComponent { | ||
14 | info: string = null | ||
15 | error: string = null | ||
16 | success: string = null | ||
17 | signupDone = false | ||
18 | |||
19 | formStepUser: FormGroup | ||
20 | formStepChannel: FormGroup | ||
21 | |||
22 | constructor ( | ||
23 | private authService: AuthService, | ||
24 | private userValidatorsService: UserValidatorsService, | ||
25 | private notifier: Notifier, | ||
26 | private userService: UserService, | ||
27 | private serverService: ServerService, | ||
28 | private redirectService: RedirectService, | ||
29 | private i18n: I18n | ||
30 | ) { | ||
31 | } | ||
32 | |||
33 | get requiresEmailVerification () { | ||
34 | return this.serverService.getConfig().signup.requiresEmailVerification | ||
35 | } | ||
36 | |||
37 | hasSameChannelAndAccountNames () { | ||
38 | return this.getUsername() === this.getChannelName() | ||
39 | } | ||
40 | |||
41 | getUsername () { | ||
42 | if (!this.formStepUser) return undefined | ||
43 | |||
44 | return this.formStepUser.value['username'] | ||
45 | } | ||
46 | |||
47 | getChannelName () { | ||
48 | if (!this.formStepChannel) return undefined | ||
49 | |||
50 | return this.formStepChannel.value['name'] | ||
51 | } | ||
52 | |||
53 | onUserFormBuilt (form: FormGroup) { | ||
54 | this.formStepUser = form | ||
55 | } | ||
56 | |||
57 | onChannelFormBuilt (form: FormGroup) { | ||
58 | this.formStepChannel = form | ||
59 | } | ||
60 | |||
61 | signup () { | ||
62 | this.error = null | ||
63 | |||
64 | const body: UserRegister = Object.assign(this.formStepUser.value, this.formStepChannel.value) | ||
65 | |||
66 | this.userService.signup(body).subscribe( | ||
67 | () => { | ||
68 | this.signupDone = true | ||
69 | |||
70 | if (this.requiresEmailVerification) { | ||
71 | this.info = this.i18n('Now please check your emails to verify your account and complete signup.') | ||
72 | return | ||
73 | } | ||
74 | |||
75 | // Auto login | ||
76 | this.authService.login(body.username, body.password) | ||
77 | .subscribe( | ||
78 | () => { | ||
79 | this.success = this.i18n('You are now logged in as {{username}}!', { username: body.username }) | ||
80 | }, | ||
81 | |||
82 | err => this.error = err.message | ||
83 | ) | ||
84 | }, | ||
85 | |||
86 | err => this.error = err.message | ||
87 | ) | ||
88 | } | ||
89 | } | ||