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 { 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<User>{
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 { 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{
}
}

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

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