diff --git a/Front/skydivelogs-app/src/services/authentication.service.ts b/Front/skydivelogs-app/src/services/authentication.service.ts index 4aee6f6..8670009 100644 --- a/Front/skydivelogs-app/src/services/authentication.service.ts +++ b/Front/skydivelogs-app/src/services/authentication.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core'; -import { HttpClient } from '@angular/common/http'; +import { HttpClient, HttpHeaders } from '@angular/common/http'; import { BehaviorSubject, Observable } from 'rxjs'; import { map } from 'rxjs/operators'; @@ -12,6 +12,9 @@ import { User } from '../models/user'; providedIn: 'root' }) export class AuthenticationService { + private readonly headers = new HttpHeaders({ + 'Access-Control-Allow-Origin': environment.apiUrl + }); private currentUserSubject: BehaviorSubject; public currentUser: Observable; @@ -25,7 +28,14 @@ export class AuthenticationService { } login(username: string, password: string) { - return this.http.post(`${environment.apiUrl}/users/authenticate`, { username, password }) + const bodyLogin = { + login: username, + password: password + }; + + return this.http.post(`${environment.apiUrl}/api/User/Authenticate`, bodyLogin, { + headers: this.headers + }) .pipe(map(user => { // store user details and basic auth credentials in local storage to keep user logged in between page refreshes user.authdata = window.btoa(username + ':' + password);