From 659783d23fc6f5ea29e8f7527cca595f3ca913e4 Mon Sep 17 00:00:00 2001 From: onsaliyo Date: Mon, 22 Feb 2021 20:09:15 +0100 Subject: [PATCH] metodos e interfaces de login actualizados --- src/app/api.service.ts | 18 ++++++------------ src/app/login.service.ts | 22 +++++++++------------- src/app/user-login.ts | 4 ++++ 3 files changed, 19 insertions(+), 25 deletions(-) create mode 100644 src/app/user-login.ts diff --git a/src/app/api.service.ts b/src/app/api.service.ts index 32381eb..b513eb1 100644 --- a/src/app/api.service.ts +++ b/src/app/api.service.ts @@ -4,30 +4,24 @@ import { Observable, throwError } from 'rxjs'; import { catchError, retry } from 'rxjs/operators'; import { User } from './user'; import { Discoteca } from './discoteca'; +import { UserLogin } from './user-login'; @Injectable({ providedIn: 'root' }) export class ApiService { + url = ''; + constructor(private http: HttpClient) { } - validateUser(loginUser: string, loginPassword: string): boolean{ - return (loginUser==''); + validateUser(user: UserLogin): Observable{ + + return this.http.post(this.url, user); } - getUser (loginUser: string): void{ - } - - postNewUser(user: User): void{ - - } - - postNewDiscoteca(discoteca: Discoteca): void{ - - } } diff --git a/src/app/login.service.ts b/src/app/login.service.ts index 2e1fcfe..f0fde60 100644 --- a/src/app/login.service.ts +++ b/src/app/login.service.ts @@ -1,30 +1,26 @@ import { Injectable } from '@angular/core'; import { ApiService } from './api.service'; import { User } from './user'; +import { UserLogin } from './user-login' @Injectable({ providedIn: 'root' }) export class LoginService { - private userId: number; - private sessionType: number; - private loginUser: string; - private loginPassword: string; + user: User; constructor(private apiService: ApiService) { } - validateUser(loginUser: string, loginPassword: string): boolean{ - return (loginUser==''); + validateUser(login: string, password: string): void{ + let user : UserLogin = { + loginUser: login, + loginPassword: password, + } + this.apiService.validateUser(user) + .subscribe((data: User) => this.user = {...data}); } - getUser (loginUser: string): void{ - - } - - postNewUser(user: User): void{ - - } } diff --git a/src/app/user-login.ts b/src/app/user-login.ts new file mode 100644 index 0000000..f0cc9b0 --- /dev/null +++ b/src/app/user-login.ts @@ -0,0 +1,4 @@ +export interface UserLogin { + loginUser: string; + loginPassword: string; +}