call login after register

pull/32/head
IvashchenkoCW 5 years ago
parent 550a232133
commit 18821e016b

@ -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<any>(`${environment.apiUrl}/auth/login/`, data)
.pipe(map(({token, user}) => {
user.token = token

@ -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

Loading…
Cancel
Save