From 18821e016b1f9fb90cc640c91bbdf75a84cb9e07 Mon Sep 17 00:00:00 2001 From: IvashchenkoCW Date: Tue, 14 Jul 2020 16:11:31 +0300 Subject: [PATCH] call login after register --- .../src/app/core/services/authentication.service.ts | 2 +- .../src/app/registration/registration.component.ts | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/composer/src/app/core/services/authentication.service.ts b/src/composer/src/app/core/services/authentication.service.ts index 44fe7e6..a8e92e6 100644 --- a/src/composer/src/app/core/services/authentication.service.ts +++ b/src/composer/src/app/core/services/authentication.service.ts @@ -21,7 +21,7 @@ export class AuthenticationService { return this.currentUserSubject.value; } - login(data: { username: string, password: string }) { + login(data: { email: string, password: string }) { return this.http.post(`${environment.apiUrl}/auth/login/`, data) .pipe(map(({token, user}) => { user.token = token diff --git a/src/composer/src/app/registration/registration.component.ts b/src/composer/src/app/registration/registration.component.ts index 6e4f7c8..eccfbcd 100644 --- a/src/composer/src/app/registration/registration.component.ts +++ b/src/composer/src/app/registration/registration.component.ts @@ -33,7 +33,16 @@ export class RegistrationComponent implements OnInit { .pipe(first()) .subscribe( data => { - this.router.navigate(['/auth/login']) + const { email, password1: password } = this.registrationForm.value + this.authenticationService.login({ email, password }) + .pipe(first()) + .subscribe( + data => { + this.router.navigate(['/']) + }, + (errors) => { + this.errors = errors + }); }, (errors) => { this.errors = errors