fix pargar and login
This commit is contained in:
@@ -33,17 +33,29 @@ class MontzarService
|
||||
|
||||
public function montzarLogin(): string
|
||||
{
|
||||
$response = Http::timeout(10)
|
||||
->acceptJson()
|
||||
->post($this->endpoint('/server/auth/login'), [
|
||||
'mobile' => $this->config()->Config('montzar_mobile'),
|
||||
'password' => $this->config()->Config('montzar_password'),
|
||||
'provider' => 'customer',
|
||||
'type_app' => 'client',
|
||||
])
|
||||
->json();
|
||||
try {
|
||||
$response = Http::timeout(10)
|
||||
->acceptJson()
|
||||
->post($this->endpoint('/server/auth/login'), [
|
||||
'mobile' => $this->config()->Config('montzar_mobile'),
|
||||
'password' => $this->config()->Config('montzar_password'),
|
||||
'provider' => 'customer',
|
||||
'type_app' => 'client',
|
||||
])
|
||||
->json();
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('Montzar login request failed', [
|
||||
'base_url' => $this->baseUrl(),
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
throw new UnprocessableEntityHttpException(
|
||||
'سرویس موقتا در دسترس نیست، لطفاً با پشتیبانی تماس بگیرید.'
|
||||
);
|
||||
}
|
||||
|
||||
$token = $response['access_token'] ?? $response['token'] ?? null;
|
||||
$token = is_array($response)
|
||||
? ($response['access_token'] ?? $response['token'] ?? null)
|
||||
: null;
|
||||
|
||||
if (!$token) {
|
||||
Log::error('Montzar login failed', [
|
||||
@@ -51,7 +63,10 @@ class MontzarService
|
||||
'mobile' => $this->config()->Config('montzar_mobile'),
|
||||
'response' => $response,
|
||||
]);
|
||||
throw new \Exception('Montzar login failed: ' . json_encode($response, JSON_UNESCAPED_UNICODE));
|
||||
// 422 تا فرانت toast نشان دهد؛ جزئیات فنی فقط در لاگ میماند
|
||||
throw new UnprocessableEntityHttpException(
|
||||
'سرویس موقتا در دسترس نیست، لطفاً با پشتیبانی تماس بگیرید.'
|
||||
);
|
||||
}
|
||||
|
||||
Setting::updateOrCreate(
|
||||
|
||||
Reference in New Issue
Block a user