]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/signup/signup.component.ts
Fix black theme on some screens
[github/Chocobozzz/PeerTube.git] / client / src / app / signup / signup.component.ts
index 607d648937b164ea1b254c8e7cfac2b63e29455e..13941ec79542e978de2e9bb05a63ea0b2b3aeec8 100644 (file)
@@ -1,8 +1,7 @@
 import { Component, OnInit } from '@angular/core'
-import { NotificationsService } from 'angular2-notifications'
+import { AuthService, Notifier, RedirectService, ServerService } from '@app/core'
 import { UserCreate } from '../../../../shared'
 import { FormReactive, UserService, UserValidatorsService } from '../shared'
-import { RedirectService, ServerService } from '@app/core'
 import { I18n } from '@ngx-translate/i18n-polyfill'
 import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
 
@@ -18,8 +17,9 @@ export class SignupComponent extends FormReactive implements OnInit {
 
   constructor (
     protected formValidatorService: FormValidatorService,
+    private authService: AuthService,
     private userValidatorsService: UserValidatorsService,
-    private notificationsService: NotificationsService,
+    private notifier: Notifier,
     private userService: UserService,
     private serverService: ServerService,
     private redirectService: RedirectService,
@@ -59,11 +59,17 @@ export class SignupComponent extends FormReactive implements OnInit {
           return
         }
 
-        this.notificationsService.success(
-          this.i18n('Success'),
-          this.i18n('Registration for {{username}} complete.', { username: userCreate.username })
-        )
-        this.redirectService.redirectToHomepage()
+        // Auto login
+        this.authService.login(userCreate.username, userCreate.password)
+            .subscribe(
+              () => {
+                this.notifier.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