cleanup login function
This commit is contained in:
@@ -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'
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|||||||
Reference in New Issue
Block a user