Merge pull request #6 from IvashchenkoCW/bugfix/login-after-register

call login after register
pull/32/head
IvashchenkoCW 5 years ago committed by GitHub
commit 57096d5932
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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