metodos e interfaces de login actualizados

This commit is contained in:
onsaliyo 2021-02-22 20:09:15 +01:00
parent b9d95793dc
commit 659783d23f
3 changed files with 19 additions and 25 deletions

View File

@ -4,30 +4,24 @@ import { Observable, throwError } from 'rxjs';
import { catchError, retry } from 'rxjs/operators'; import { catchError, retry } from 'rxjs/operators';
import { User } from './user'; import { User } from './user';
import { Discoteca } from './discoteca'; import { Discoteca } from './discoteca';
import { UserLogin } from './user-login';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
export class ApiService { export class ApiService {
url = '';
constructor(private http: HttpClient) { constructor(private http: HttpClient) {
} }
validateUser(loginUser: string, loginPassword: string): boolean{ validateUser(user: UserLogin): Observable<User>{
return (loginUser=='');
return this.http.post<User>(this.url, user);
} }
getUser (loginUser: string): void{
} }
postNewUser(user: User): void{
}
postNewDiscoteca(discoteca: Discoteca): void{
}
}

View File

@ -1,30 +1,26 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { ApiService } from './api.service'; import { ApiService } from './api.service';
import { User } from './user'; import { User } from './user';
import { UserLogin } from './user-login'
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
export class LoginService { export class LoginService {
private userId: number; user: User;
private sessionType: number;
private loginUser: string;
private loginPassword: string;
constructor(private apiService: ApiService) { constructor(private apiService: ApiService) {
} }
validateUser(loginUser: string, loginPassword: string): boolean{ validateUser(login: string, password: string): void{
return (loginUser==''); 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{
}
} }

4
src/app/user-login.ts Normal file
View File

@ -0,0 +1,4 @@
export interface UserLogin {
loginUser: string;
loginPassword: string;
}