Modif des services avec l'utilisation d'un "BaseService"
This commit is contained in:
@@ -1,24 +1,23 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import { environment } from '../environments/environment';
|
||||
import { User } from '../models/user';
|
||||
import { BaseService } from './base.service';
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class AuthenticationService {
|
||||
private readonly headers = new HttpHeaders({
|
||||
'Access-Control-Allow-Origin': environment.apiUrl
|
||||
});
|
||||
export class AuthenticationService extends BaseService {
|
||||
private currentUserSubject: BehaviorSubject<User>;
|
||||
public currentUser: Observable<User>;
|
||||
|
||||
constructor(private http: HttpClient) {
|
||||
super();
|
||||
|
||||
this.currentUserSubject = new BehaviorSubject<User>(JSON.parse(localStorage.getItem('currentUser')));
|
||||
this.currentUser = this.currentUserSubject.asObservable();
|
||||
}
|
||||
@@ -33,7 +32,7 @@ export class AuthenticationService {
|
||||
password: password
|
||||
};
|
||||
|
||||
return this.http.post<any>(`${environment.apiUrl}/api/User/Authenticate`, bodyLogin, {
|
||||
return this.http.post<any>(`${this.apiUrl}/User/Authenticate`, bodyLogin, {
|
||||
headers: this.headers
|
||||
})
|
||||
.pipe(map(user => {
|
||||
|
||||
Reference in New Issue
Block a user