connexion avec le backend pour la page login
This commit is contained in:
parent
9566d11dd7
commit
22f6d316b4
5 changed files with 78 additions and 18 deletions
|
|
@ -1,9 +1,38 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import {HttpClient, HttpParams} from "@angular/common/http";
|
||||
import {Observable} from "rxjs";
|
||||
import {environment} from "../../../../environments/environment";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class MessageService {
|
||||
export class MessageService
|
||||
{
|
||||
|
||||
constructor( private http: HttpClient ) { }
|
||||
|
||||
post(url: string, data: any): Observable<any>
|
||||
{
|
||||
const urlComplete = environment.debutUrl + url ;
|
||||
return this.http.post<any>(urlComplete, data, {withCredentials: true});
|
||||
}
|
||||
|
||||
get(url: string, params:HttpParams = new HttpParams()): Observable<any>
|
||||
{
|
||||
const urlComplete = environment.debutUrl + url ;
|
||||
return this.http.get<any>(urlComplete,{ withCredentials: true, params: params });
|
||||
}
|
||||
|
||||
put(url: string, data: any): Observable<any>
|
||||
{
|
||||
const urlComplete = environment.debutUrl + url ;
|
||||
return this.http.put<any>(urlComplete, data, {withCredentials: true});
|
||||
}
|
||||
|
||||
delete(url: string): Observable<any>
|
||||
{
|
||||
const urlComplete = environment.debutUrl + url ;
|
||||
return this.http.delete<any>(urlComplete,{withCredentials: true});
|
||||
}
|
||||
|
||||
constructor() { }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,34 @@ import { Injectable } from '@angular/core';
|
|||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ProfilService {
|
||||
export class ProfilService
|
||||
{
|
||||
|
||||
getId(): number | null
|
||||
{
|
||||
let idString = localStorage.getItem('id');
|
||||
if(idString === null) return null;
|
||||
else return parseInt(idString);
|
||||
}
|
||||
|
||||
setId(id: number): void
|
||||
{
|
||||
localStorage.setItem('id', id.toString());
|
||||
}
|
||||
|
||||
getIsAdmin(): boolean
|
||||
{
|
||||
let isAdminString = localStorage.getItem('isAdmin');
|
||||
if(isAdminString === "T") return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
setIsAdmin(isAdmin: boolean): void
|
||||
{
|
||||
let isAdminString = "" ;
|
||||
if(isAdmin) isAdminString = "T";
|
||||
else isAdminString = "F";
|
||||
localStorage.setItem('isAdmin', isAdminString);
|
||||
}
|
||||
|
||||
constructor() { }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue