postLoginCall() refactored

This commit is contained in:
Julius Gruber
2019-06-18 10:51:52 +02:00
parent a36aa50d16
commit 8ed359cc7e

View File

@@ -20,6 +20,7 @@ import { CoreState } from '../../core/core.reducers';
import {isNotEmpty} from '../empty.util';
import {fadeOut} from '../animations/fade';
import {AuthService} from '../../core/auth/auth.service';
import {HttpClient} from '@angular/common/http';
/**
* /users/sign-in
@@ -102,7 +103,8 @@ export class LogInComponent implements OnDestroy, OnInit {
constructor(
private authService: AuthService,
private formBuilder: FormBuilder,
private store: Store<CoreState>
private store: Store<CoreState>,
private http: HttpClient
) {
}
@@ -207,9 +209,27 @@ export class LogInComponent implements OnDestroy, OnInit {
this.form.reset();
}
postLoginCall() {
const email = '';
const password = '';
this.store.dispatch(new AuthenticateAction(email, password));
public postLoginCall() {
console.log('postLoginCall() was called');
/* const email = 'test@test.at';
const password = 'test';
this.store.dispatch(new AuthenticateAction(email, password));*/
this.http.post('https://fis.tiss.tuwien.ac.at/spring-rest/api/authn/login',
{
name: 'morpheus',
job: 'leader'
})
.subscribe(
(val) => {
console.log('POST call successful value returned in body',
val);
},
(response) => {
console.log('POST call in error', response);
},
() => {
console.log('The POST observable is now completed.');
});
}
}