mirror of https://github.com/Chocobozzz/PeerTube
Auto login user on signup
parent
d8c9996ce2
commit
43e9d2af7d
|
@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core'
|
||||||
import { NotificationsService } from 'angular2-notifications'
|
import { NotificationsService } from 'angular2-notifications'
|
||||||
import { UserCreate } from '../../../../shared'
|
import { UserCreate } from '../../../../shared'
|
||||||
import { FormReactive, UserService, UserValidatorsService } from '../shared'
|
import { FormReactive, UserService, UserValidatorsService } from '../shared'
|
||||||
import { RedirectService, ServerService } from '@app/core'
|
import { AuthService, RedirectService, ServerService } from '@app/core'
|
||||||
import { I18n } from '@ngx-translate/i18n-polyfill'
|
import { I18n } from '@ngx-translate/i18n-polyfill'
|
||||||
import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
|
import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ export class SignupComponent extends FormReactive implements OnInit {
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
protected formValidatorService: FormValidatorService,
|
protected formValidatorService: FormValidatorService,
|
||||||
|
private authService: AuthService,
|
||||||
private userValidatorsService: UserValidatorsService,
|
private userValidatorsService: UserValidatorsService,
|
||||||
private notificationsService: NotificationsService,
|
private notificationsService: NotificationsService,
|
||||||
private userService: UserService,
|
private userService: UserService,
|
||||||
|
@ -59,11 +60,20 @@ export class SignupComponent extends FormReactive implements OnInit {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.notificationsService.success(
|
// Auto login
|
||||||
this.i18n('Success'),
|
this.authService.login(userCreate.username, userCreate.password)
|
||||||
this.i18n('Registration for {{username}} complete.', { username: userCreate.username })
|
.subscribe(
|
||||||
)
|
() => {
|
||||||
this.redirectService.redirectToHomepage()
|
this.notificationsService.success(
|
||||||
|
this.i18n('Success'),
|
||||||
|
this.i18n('You are now logged in as {{username}}!', { username: userCreate.username })
|
||||||
|
)
|
||||||
|
|
||||||
|
this.redirectService.redirectToHomepage()
|
||||||
|
},
|
||||||
|
|
||||||
|
err => this.error = err.message
|
||||||
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
err => this.error = err.message
|
err => this.error = err.message
|
||||||
|
|
Loading…
Reference in New Issue