postLoginCall() refactored

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

View File

@@ -1,9 +1,9 @@
import { filter, map, takeWhile } from 'rxjs/operators'; import {filter, map, takeWhile} from 'rxjs/operators';
import { Component, OnDestroy, OnInit } from '@angular/core'; import {Component, OnDestroy, OnInit} from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import { select, Store } from '@ngrx/store'; import {select, Store} from '@ngrx/store';
import { Observable } from 'rxjs'; import {Observable} from 'rxjs';
import { import {
AuthenticateAction, AuthenticateAction,
ResetAuthenticationMessagesAction ResetAuthenticationMessagesAction
@@ -15,11 +15,12 @@ import {
isAuthenticated, isAuthenticated,
isAuthenticationLoading, isAuthenticationLoading,
} from '../../core/auth/selectors'; } from '../../core/auth/selectors';
import { CoreState } from '../../core/core.reducers'; import {CoreState} from '../../core/core.reducers';
import { isNotEmpty } from '../empty.util'; import {isNotEmpty} from '../empty.util';
import { fadeOut } from '../animations/fade'; import {fadeOut} from '../animations/fade';
import { AuthService } from '../../core/auth/auth.service'; import {AuthService} from '../../core/auth/auth.service';
import {HttpClient} from '@angular/common/http';
/** /**
* /users/sign-in * /users/sign-in
@@ -102,7 +103,8 @@ export class LogInComponent implements OnDestroy, OnInit {
constructor( constructor(
private authService: AuthService, private authService: AuthService,
private formBuilder: FormBuilder, 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(); this.form.reset();
} }
postLoginCall() { public postLoginCall() {
const email = ''; console.log('postLoginCall() was called');
const password = ''; /* const email = 'test@test.at';
this.store.dispatch(new AuthenticateAction(email, password)); 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.');
});
} }
} }