mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 08:24:39 -04:00
Merge pull request #5261 from beganovich/v4-2603-improve-authentication-process
(v4) Improve authentication workflow
This commit is contained in:
commit
3d69498c6e
@ -53,18 +53,18 @@ class AuthService
|
|||||||
|
|
||||||
$body = Body::json($data);
|
$body = Body::json($data);
|
||||||
|
|
||||||
try {
|
$response = Request::post($this->getUrl(), $this->getHeaders(), $body);
|
||||||
$response = Request::post($this->getUrl(), $this->getHeaders(), $body);
|
|
||||||
|
|
||||||
|
if (in_array($response->code, [401])) {
|
||||||
|
info($response->raw_body);
|
||||||
|
|
||||||
|
$this->isSuccessful = false;
|
||||||
|
$this->processErrors($response->body->message);
|
||||||
|
} elseif (in_array($response->code, [200])) {
|
||||||
$this->isSuccessful = true;
|
$this->isSuccessful = true;
|
||||||
$this->token = $response->body->data[0]->token->token;
|
$this->token = $response->body->data[0]->token->token;
|
||||||
|
} else {
|
||||||
if (in_array($response->code, [401, 422, 500])) {
|
info($response->raw_body);
|
||||||
$this->isSuccessful = false;
|
|
||||||
$this->processErrors($response->body);
|
|
||||||
}
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
info($e->getMessage());
|
|
||||||
|
|
||||||
$this->isSuccessful = false;
|
$this->isSuccessful = false;
|
||||||
$this->errors = [trans('texts.migration_went_wrong')];
|
$this->errors = [trans('texts.migration_went_wrong')];
|
||||||
@ -118,7 +118,7 @@ class AuthService
|
|||||||
|
|
||||||
private function processErrors($errors)
|
private function processErrors($errors)
|
||||||
{
|
{
|
||||||
$array = (array) $errors;
|
$array = (array)$errors;
|
||||||
|
|
||||||
$this->errors = $array;
|
$this->errors = $array;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user