diff options
Diffstat (limited to 'client/src/app/signup/signup.component.ts')
-rw-r--r-- | client/src/app/signup/signup.component.ts | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/client/src/app/signup/signup.component.ts b/client/src/app/signup/signup.component.ts index cf2657b85..3341d4e09 100644 --- a/client/src/app/signup/signup.component.ts +++ b/client/src/app/signup/signup.component.ts | |||
@@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core' | |||
2 | import { NotificationsService } from 'angular2-notifications' | 2 | import { NotificationsService } from 'angular2-notifications' |
3 | import { UserCreate } from '../../../../shared' | 3 | import { UserCreate } from '../../../../shared' |
4 | import { FormReactive, UserService, UserValidatorsService } from '../shared' | 4 | import { FormReactive, UserService, UserValidatorsService } from '../shared' |
5 | import { RedirectService, ServerService } from '@app/core' | 5 | import { AuthService, RedirectService, ServerService } from '@app/core' |
6 | import { I18n } from '@ngx-translate/i18n-polyfill' | 6 | import { I18n } from '@ngx-translate/i18n-polyfill' |
7 | import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' | 7 | import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' |
8 | 8 | ||
@@ -12,10 +12,13 @@ import { FormValidatorService } from '@app/shared/forms/form-validators/form-val | |||
12 | styleUrls: [ './signup.component.scss' ] | 12 | styleUrls: [ './signup.component.scss' ] |
13 | }) | 13 | }) |
14 | export class SignupComponent extends FormReactive implements OnInit { | 14 | export class SignupComponent extends FormReactive implements OnInit { |
15 | info: string = null | ||
15 | error: string = null | 16 | error: string = null |
17 | signupDone = false | ||
16 | 18 | ||
17 | constructor ( | 19 | constructor ( |
18 | protected formValidatorService: FormValidatorService, | 20 | protected formValidatorService: FormValidatorService, |
21 | private authService: AuthService, | ||
19 | private userValidatorsService: UserValidatorsService, | 22 | private userValidatorsService: UserValidatorsService, |
20 | private notificationsService: NotificationsService, | 23 | private notificationsService: NotificationsService, |
21 | private userService: UserService, | 24 | private userService: UserService, |
@@ -50,18 +53,27 @@ export class SignupComponent extends FormReactive implements OnInit { | |||
50 | 53 | ||
51 | this.userService.signup(userCreate).subscribe( | 54 | this.userService.signup(userCreate).subscribe( |
52 | () => { | 55 | () => { |
56 | this.signupDone = true | ||
57 | |||
53 | if (this.requiresEmailVerification) { | 58 | if (this.requiresEmailVerification) { |
54 | this.notificationsService.alert( | 59 | this.info = this.i18n('Welcome! Now please check your emails to verify your account and complete signup.') |
55 | this.i18n('Welcome'), | 60 | return |
56 | this.i18n('Please check your email to verify your account and complete signup.') | ||
57 | ) | ||
58 | } else { | ||
59 | this.notificationsService.success( | ||
60 | this.i18n('Success'), | ||
61 | this.i18n('Registration for {{username}} complete.', { username: userCreate.username }) | ||
62 | ) | ||
63 | } | 61 | } |
64 | this.redirectService.redirectToHomepage() | 62 | |
63 | // Auto login | ||
64 | this.authService.login(userCreate.username, userCreate.password) | ||
65 | .subscribe( | ||
66 | () => { | ||
67 | this.notificationsService.success( | ||
68 | this.i18n('Success'), | ||
69 | this.i18n('You are now logged in as {{username}}!', { username: userCreate.username }) | ||
70 | ) | ||
71 | |||
72 | this.redirectService.redirectToHomepage() | ||
73 | }, | ||
74 | |||
75 | err => this.error = err.message | ||
76 | ) | ||
65 | }, | 77 | }, |
66 | 78 | ||
67 | err => this.error = err.message | 79 | err => this.error = err.message |