error body message
This commit is contained in:
@@ -32,6 +32,7 @@ namespace Espo\Core\Authentication;
|
||||
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Exceptions\NotFound;
|
||||
use Espo\Core\Utils\Language;
|
||||
use Espo\Repositories\UserData as UserDataRepository;
|
||||
use Espo\Entities\Portal;
|
||||
use Espo\Entities\User;
|
||||
@@ -87,7 +88,8 @@ class Authentication
|
||||
private Log $log,
|
||||
private LogoutFactory $logoutFactory,
|
||||
private MethodProvider $methodProvider,
|
||||
private Util $util
|
||||
private Util $util,
|
||||
private Language $language
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -204,8 +206,7 @@ class Authentication
|
||||
throw ServiceUnavailable::createWithBody(
|
||||
"Application is in maintenance mod1e.",
|
||||
Body::create()
|
||||
->withMessageTranslation('maintenanceModeError', 'messages')
|
||||
->encode()
|
||||
->withMessage($this->language->translateLabel('maintenanceModeError', 'messages'))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ class Body
|
||||
private ?string $messageTranslationScope = null;
|
||||
/** @var ?array<string, string> */
|
||||
private ?array $messageTranslationData = null;
|
||||
private ?string $message = null;
|
||||
|
||||
public static function create(): self
|
||||
{
|
||||
@@ -63,6 +64,14 @@ class Body
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public function withMessage(string $message): self
|
||||
{
|
||||
$obj = clone $this;
|
||||
$obj->message = $message;
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public function encode(): string
|
||||
{
|
||||
$data = (object) [];
|
||||
@@ -77,6 +86,10 @@ class Body
|
||||
];
|
||||
}
|
||||
|
||||
if ($this->message) {
|
||||
$data->message = $this->message;
|
||||
}
|
||||
|
||||
return Json::encode($data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1308,6 +1308,18 @@ class App {
|
||||
|
||||
isMessageDone = true;
|
||||
}
|
||||
|
||||
if (
|
||||
!isMessageDone &&
|
||||
data &&
|
||||
'message'in data &&
|
||||
data.message
|
||||
) {
|
||||
obj.msg += '\n' + data.message;
|
||||
obj.closeButton = true;
|
||||
|
||||
isMessageDone = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isMessageDone) {
|
||||
|
||||
Reference in New Issue
Block a user