fix pargar login
This commit is contained in:
@@ -35,11 +35,10 @@ class PargarInboundController extends Controller
|
||||
], 503);
|
||||
}
|
||||
|
||||
$username = (string) $request->input('username', '');
|
||||
$password = (string) $request->input('password', '');
|
||||
[$username, $password] = $this->pargarLoginCredentials($request);
|
||||
|
||||
$expectedUser = trim((string) $this->Config('pargar_username'));
|
||||
$expectedPass = trim((string) $this->Config('pargar_password'));
|
||||
$expectedUser = $this->normalizeCredential(trim((string) $this->Config('pargar_username')));
|
||||
$expectedPass = $this->normalizeCredential(trim((string) $this->Config('pargar_password')));
|
||||
|
||||
if ($username !== $expectedUser || $password !== $expectedPass || $expectedUser === '') {
|
||||
return response()->json([
|
||||
@@ -389,6 +388,37 @@ class PargarInboundController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{0: string, 1: string}
|
||||
*/
|
||||
private function pargarLoginCredentials(Request $request): array
|
||||
{
|
||||
$username = (string) $request->input('username', '');
|
||||
$password = (string) $request->input('password', '');
|
||||
|
||||
if ($username === '' && $password === '') {
|
||||
$payload = json_decode((string) $request->getContent(), true);
|
||||
if (is_array($payload)) {
|
||||
$username = (string) ($payload['username'] ?? '');
|
||||
$password = (string) ($payload['password'] ?? '');
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
$this->normalizeCredential($username),
|
||||
$this->normalizeCredential($password),
|
||||
];
|
||||
}
|
||||
|
||||
private function normalizeCredential(string $value): string
|
||||
{
|
||||
$persian = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'];
|
||||
$arabic = ['٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩'];
|
||||
$latin = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
|
||||
|
||||
return trim(str_replace(array_merge($persian, $arabic), array_merge($latin, $latin), $value));
|
||||
}
|
||||
|
||||
private function uniqueReferralId(): string
|
||||
{
|
||||
do {
|
||||
|
||||
Reference in New Issue
Block a user