BackEnd #3
|
@ -21,9 +21,11 @@ export class ApiService {
|
||||||
|
|
||||||
validateUser(user: UserLogin): Observable<User>{
|
validateUser(user: UserLogin): Observable<User>{
|
||||||
|
|
||||||
return this.http.post<User>("http://localhost:3307/api/consultas/users", user);
|
return this.http.post<User>("http://localhost:3307/api/consultas/users", user)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
import { VirtualTimeScheduler } from 'rxjs';
|
||||||
import { ApiService } from './api.service';
|
import { ApiService } from './api.service';
|
||||||
import { User } from './user';
|
import { User } from './user';
|
||||||
import { UserLogin } from './user-login';
|
import { UserLogin } from './user-login';
|
||||||
|
@ -21,7 +22,7 @@ export class LoginService {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
validateUser(login: string, password: string): User {
|
validateUser(login: string, password: string): void{
|
||||||
|
|
||||||
let userlogin: UserLogin = {
|
let userlogin: UserLogin = {
|
||||||
loginUser: login,
|
loginUser: login,
|
||||||
|
@ -29,12 +30,12 @@ export class LoginService {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.apiService.validateUser(userlogin)
|
this.apiService.validateUser(userlogin)
|
||||||
.subscribe(user => this.user = user)
|
.subscribe(user => {
|
||||||
|
this.user = user;
|
||||||
return this.user;
|
console.log(this.user);
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,12 +20,12 @@ export class LoginPage implements OnInit {
|
||||||
this.user = this.loginService.user;
|
this.user = this.loginService.user;
|
||||||
}
|
}
|
||||||
|
|
||||||
async login() {
|
login() {
|
||||||
|
|
||||||
this.username = (<HTMLInputElement>document.getElementById("username")).value;
|
this.username = (<HTMLInputElement>document.getElementById("username")).value;
|
||||||
this.password = (<HTMLInputElement>document.getElementById("password")).value;
|
this.password = (<HTMLInputElement>document.getElementById("password")).value;
|
||||||
this.user = await this.loginService.validateUser(this.username, this.password);
|
this.loginService.validateUser(this.username, this.password)
|
||||||
console.log(this.user.username);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue