|
|
@@ -0,0 +1,30 @@ |
|
|
|
import { Injectable } from '@angular/core'; |
|
|
|
import { HttpClient, HttpHeaders } from '@angular/common/http'; |
|
|
|
import { lastValueFrom } from 'rxjs'; |
|
|
|
import { BASE_URL } from './partner-profile.service'; |
|
|
|
|
|
|
|
@Injectable({ |
|
|
|
providedIn: 'root' |
|
|
|
}) |
|
|
|
export class AuthService { |
|
|
|
|
|
|
|
constructor( |
|
|
|
private http: HttpClient |
|
|
|
) { } |
|
|
|
|
|
|
|
async authenticateUser(credentials: { |
|
|
|
username: string, |
|
|
|
password: string, |
|
|
|
}) { |
|
|
|
const body = `&username=${encodeURIComponent(credentials.username)}&password=${encodeURIComponent(credentials.password)}`; |
|
|
|
const headers = new HttpHeaders({ |
|
|
|
Accept: 'text/html, application/xhtml+xml, */*', |
|
|
|
'Content-Type': 'application/x-www-form-urlencoded', |
|
|
|
}); |
|
|
|
const httpOptions = { |
|
|
|
headers, |
|
|
|
responseType: 'text' as 'json', |
|
|
|
}; |
|
|
|
return lastValueFrom(this.http.post(BASE_URL + '/api-auth/', body, httpOptions)); |
|
|
|
} |
|
|
|
} |