diff options
author | Chocobozzz <me@florianbigard.com> | 2018-11-16 17:06:19 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-11-16 17:06:19 +0100 |
commit | 43e9d2af7d3525bc709e4c6d15fe85f65795f5fa (patch) | |
tree | df1cd014a6dfbe7627ce67562fd8dbcd9ccc4749 | |
parent | d8c9996ce2b4de3ef1f2d36f63e461006bab58ed (diff) | |
download | PeerTube-43e9d2af7d3525bc709e4c6d15fe85f65795f5fa.tar.gz PeerTube-43e9d2af7d3525bc709e4c6d15fe85f65795f5fa.tar.zst PeerTube-43e9d2af7d3525bc709e4c6d15fe85f65795f5fa.zip |
Auto login user on signup
-rw-r--r-- | client/src/app/signup/signup.component.ts | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/client/src/app/signup/signup.component.ts b/client/src/app/signup/signup.component.ts index 607d64893..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 | ||
@@ -18,6 +18,7 @@ export class SignupComponent extends FormReactive implements OnInit { | |||
18 | 18 | ||
19 | constructor ( | 19 | constructor ( |
20 | protected formValidatorService: FormValidatorService, | 20 | protected formValidatorService: FormValidatorService, |
21 | private authService: AuthService, | ||
21 | private userValidatorsService: UserValidatorsService, | 22 | private userValidatorsService: UserValidatorsService, |
22 | private notificationsService: NotificationsService, | 23 | private notificationsService: NotificationsService, |
23 | private userService: UserService, | 24 | private userService: UserService, |
@@ -59,11 +60,20 @@ export class SignupComponent extends FormReactive implements OnInit { | |||
59 | return | 60 | return |
60 | } | 61 | } |
61 | 62 | ||
62 | this.notificationsService.success( | 63 | // Auto login |
63 | this.i18n('Success'), | 64 | this.authService.login(userCreate.username, userCreate.password) |
64 | this.i18n('Registration for {{username}} complete.', { username: userCreate.username }) | 65 | .subscribe( |
65 | ) | 66 | () => { |
66 | this.redirectService.redirectToHomepage() | 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 | ) | ||
67 | }, | 77 | }, |
68 | 78 | ||
69 | err => this.error = err.message | 79 | err => this.error = err.message |