mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 20:24:30 -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);
|
||||
|
||||
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->token = $response->body->data[0]->token->token;
|
||||
|
||||
if (in_array($response->code, [401, 422, 500])) {
|
||||
$this->isSuccessful = false;
|
||||
$this->processErrors($response->body);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
info($e->getMessage());
|
||||
} else {
|
||||
info($response->raw_body);
|
||||
|
||||
$this->isSuccessful = false;
|
||||
$this->errors = [trans('texts.migration_went_wrong')];
|
||||
@ -118,7 +118,7 @@ class AuthService
|
||||
|
||||
private function processErrors($errors)
|
||||
{
|
||||
$array = (array) $errors;
|
||||
$array = (array)$errors;
|
||||
|
||||
$this->errors = $array;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user