cleanup login function

This commit is contained in:
2026-07-22 16:15:00 +02:00
parent 99a4f2787b
commit 6e3665696c
@@ -23,12 +23,15 @@ class ElixFormsAuthenticationClient {
* @throws ElixFormsException Se le credenziali sono errate o c'è un errore server * @throws ElixFormsException Se le credenziali sono errate o c'è un errore server
*/ */
public function login(string $username, string $password): string { public function login(string $username, string $password): string {
$this->baseUrl = rtrim($this->baseUrl,'/');
$url = "{$this->baseUrl}/services/api/authentication/login/v1"; $url = "{$this->baseUrl}/services/api/authentication/login/v1";
try { try {
$response = $this->httpClient->post($url, [ $response = $this->httpClient->post($url, [
'form_params' => [ 'headers' => [
'x-requested-with' => 'XMLHttpRequest',
'Content-Type' => 'application/json'
],
'json' => [
'username' => $username, 'username' => $username,
'password' => $password 'password' => $password
] ]
@@ -70,7 +73,7 @@ class ElixFormsAuthenticationClient {
try { try {
$response = $this->httpClient->post($url, [ $response = $this->httpClient->post($url, [
'headers' => [ 'headers' => [
'Authorization' => 'Bearer ' . $token, 'Authorization' => "Bearer {$token}",
'Content-Type' => 'application/x-www-form-urlencoded' 'Content-Type' => 'application/x-www-form-urlencoded'
] ]
]); ]);