metodos e interfaces de login actualizados
This commit is contained in:
parent
b9d95793dc
commit
659783d23f
|
@ -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{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
export interface UserLogin {
|
||||
loginUser: string;
|
||||
loginPassword: string;
|
||||
}
|
Loading…
Reference in New Issue