aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/signup/signup.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/signup/signup.component.ts')
-rw-r--r--client/src/app/signup/signup.component.ts34
1 files changed, 21 insertions, 13 deletions
diff --git a/client/src/app/signup/signup.component.ts b/client/src/app/signup/signup.component.ts
index cf2657b85..13941ec79 100644
--- a/client/src/app/signup/signup.component.ts
+++ b/client/src/app/signup/signup.component.ts
@@ -1,8 +1,7 @@
1import { Component, OnInit } from '@angular/core' 1import { Component, OnInit } from '@angular/core'
2import { NotificationsService } from 'angular2-notifications' 2import { AuthService, Notifier, RedirectService, ServerService } from '@app/core'
3import { UserCreate } from '../../../../shared' 3import { UserCreate } from '../../../../shared'
4import { FormReactive, UserService, UserValidatorsService } from '../shared' 4import { FormReactive, UserService, UserValidatorsService } from '../shared'
5import { RedirectService, ServerService } from '@app/core'
6import { I18n } from '@ngx-translate/i18n-polyfill' 5import { I18n } from '@ngx-translate/i18n-polyfill'
7import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' 6import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
8 7
@@ -12,12 +11,15 @@ import { FormValidatorService } from '@app/shared/forms/form-validators/form-val
12 styleUrls: [ './signup.component.scss' ] 11 styleUrls: [ './signup.component.scss' ]
13}) 12})
14export class SignupComponent extends FormReactive implements OnInit { 13export class SignupComponent extends FormReactive implements OnInit {
14 info: string = null
15 error: string = null 15 error: string = null
16 signupDone = false
16 17
17 constructor ( 18 constructor (
18 protected formValidatorService: FormValidatorService, 19 protected formValidatorService: FormValidatorService,
20 private authService: AuthService,
19 private userValidatorsService: UserValidatorsService, 21 private userValidatorsService: UserValidatorsService,
20 private notificationsService: NotificationsService, 22 private notifier: Notifier,
21 private userService: UserService, 23 private userService: UserService,
22 private serverService: ServerService, 24 private serverService: ServerService,
23 private redirectService: RedirectService, 25 private redirectService: RedirectService,
@@ -50,18 +52,24 @@ export class SignupComponent extends FormReactive implements OnInit {
50 52
51 this.userService.signup(userCreate).subscribe( 53 this.userService.signup(userCreate).subscribe(
52 () => { 54 () => {
55 this.signupDone = true
56
53 if (this.requiresEmailVerification) { 57 if (this.requiresEmailVerification) {
54 this.notificationsService.alert( 58 this.info = this.i18n('Welcome! Now please check your emails to verify your account and complete signup.')
55 this.i18n('Welcome'), 59 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 } 60 }
64 this.redirectService.redirectToHomepage() 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 )
65 }, 73 },
66 74
67 err => this.error = err.message 75 err => this.error = err.message