Surface specific Jibit identity errors on profile update.
Map Shahkar mismatch, token, unreachable, and duplicate cases to clear Persian messages instead of a generic wait-for-admin toast. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -830,33 +830,60 @@ class Controller extends BaseController
|
||||
Storage::put('refreshTokenGibit', 'توکن رفرش اولیه');
|
||||
}
|
||||
|
||||
$apiData['refresh'] = Http::withoutVerifying()->withToken(Storage::get('refreshTokenGibit'))
|
||||
->post('https://napi.jibit.ir/ide/v1/tokens/generate', [
|
||||
'apiKey' => 'J5WxrPxPOg',
|
||||
'secretKey' => '7dgeE70xQXsQL7r36j3wif6X9',
|
||||
])->json();
|
||||
$apiData['refresh'] = $this->jibitHttpJson(
|
||||
Http::withoutVerifying()->withToken(Storage::get('refreshTokenGibit'))
|
||||
->post('https://napi.jibit.ir/ide/v1/tokens/generate', [
|
||||
'apiKey' => 'J5WxrPxPOg',
|
||||
'secretKey' => '7dgeE70xQXsQL7r36j3wif6X9',
|
||||
])
|
||||
);
|
||||
Storage::put('accessTokenGibit', $apiData['refresh']['accessToken'] ?? '');
|
||||
if (!empty($apiData['refresh']['refreshToken'])) {
|
||||
Storage::put('refreshTokenGibit', $apiData['refresh']['refreshToken']);
|
||||
}
|
||||
|
||||
$response = Http::withoutVerifying()->withToken(Storage::get('accessTokenGibit'))
|
||||
->get("https://napi.jibit.ir/ide/v1/services/matching?mobileNumber=$mobile&nationalCode=$nationalCode")
|
||||
->json();
|
||||
if (empty($apiData['refresh']['accessToken'])) {
|
||||
return [
|
||||
'code' => 'token_failed',
|
||||
'http_status' => $apiData['refresh']['http_status'] ?? null,
|
||||
'message' => $apiData['refresh']['message'] ?? '',
|
||||
];
|
||||
}
|
||||
|
||||
if ((isset($response['code'])) && $response['code'] == 'forbidden') {
|
||||
$refreshToken = Http::withoutVerifying()->withToken(Storage::get('refreshTokenGibit'))
|
||||
->post('https://napi.jibit.ir/ide/v1/tokens/generate', [
|
||||
'apiKey' => 'J5WxrPxPOg',
|
||||
'secretKey' => '7dgeE70xQXsQL7r36j3wif6X9',
|
||||
])->json();
|
||||
$response = $this->jibitHttpJson(
|
||||
Http::withoutVerifying()->withToken(Storage::get('accessTokenGibit'))
|
||||
->get('https://napi.jibit.ir/ide/v1/services/matching', [
|
||||
'mobileNumber' => $mobile,
|
||||
'nationalCode' => $nationalCode,
|
||||
])
|
||||
);
|
||||
|
||||
if (($response['code'] ?? null) == 'forbidden') {
|
||||
$refreshToken = $this->jibitHttpJson(
|
||||
Http::withoutVerifying()->withToken(Storage::get('refreshTokenGibit'))
|
||||
->post('https://napi.jibit.ir/ide/v1/tokens/generate', [
|
||||
'apiKey' => 'J5WxrPxPOg',
|
||||
'secretKey' => '7dgeE70xQXsQL7r36j3wif6X9',
|
||||
])
|
||||
);
|
||||
Storage::put('accessTokenGibit', $refreshToken['accessToken'] ?? '');
|
||||
if (!empty($refreshToken['refreshToken'])) {
|
||||
Storage::put('refreshTokenGibit', $refreshToken['refreshToken']);
|
||||
}
|
||||
$response = Http::withoutVerifying()->withToken(Storage::get('accessTokenGibit'))
|
||||
->get("https://napi.jibit.ir/ide/v1/services/matching?mobileNumber=$mobile&nationalCode=$nationalCode")
|
||||
->json();
|
||||
if (empty($refreshToken['accessToken'])) {
|
||||
return [
|
||||
'code' => 'token_failed',
|
||||
'http_status' => $refreshToken['http_status'] ?? null,
|
||||
'message' => $refreshToken['message'] ?? '',
|
||||
];
|
||||
}
|
||||
$response = $this->jibitHttpJson(
|
||||
Http::withoutVerifying()->withToken(Storage::get('accessTokenGibit'))
|
||||
->get('https://napi.jibit.ir/ide/v1/services/matching', [
|
||||
'mobileNumber' => $mobile,
|
||||
'nationalCode' => $nationalCode,
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
$counter->value = (int) $counter->value + 1;
|
||||
@@ -865,6 +892,25 @@ class Controller extends BaseController
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Illuminate\Http\Client\Response $pending
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function jibitHttpJson($pending): array
|
||||
{
|
||||
$decoded = $pending->json();
|
||||
if (! is_array($decoded)) {
|
||||
return [
|
||||
'code' => 'empty_response',
|
||||
'http_status' => $pending->status(),
|
||||
'message' => '',
|
||||
];
|
||||
}
|
||||
$decoded['http_status'] = $pending->status();
|
||||
|
||||
return $decoded;
|
||||
}
|
||||
|
||||
public static function jibit($method, $p1 = null, $p2 = null, $p3 = null)
|
||||
{
|
||||
if (!app(ConfigService::class)->isJibitEnabled()) {
|
||||
|
||||
Reference in New Issue
Block a user