Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed6e34cc4b | ||
|
|
bb13eb74e8 |
@@ -172,7 +172,7 @@ function sendNabehOtp(string $receiver, string $otp, string $method = 'text'): b
|
|||||||
* @param string $method whatsapp | sms | voice | flash_call
|
* @param string $method whatsapp | sms | voice | flash_call
|
||||||
* @return bool True if OTP was sent successfully
|
* @return bool True if OTP was sent successfully
|
||||||
*/
|
*/
|
||||||
function sendIntaleqOtp(string $receiver, string $otp, string $method = 'whatsapp'): bool {
|
function sendIntaleqOtp(string $receiver, string &$otp, string $method = 'whatsapp'): bool {
|
||||||
$appKey = getenv('NABEH_OTP_APP_KEY');
|
$appKey = getenv('NABEH_OTP_APP_KEY');
|
||||||
|
|
||||||
if (!$appKey) {
|
if (!$appKey) {
|
||||||
@@ -186,10 +186,7 @@ function sendIntaleqOtp(string $receiver, string $otp, string $method = 'whatsap
|
|||||||
$apiUrl = 'https://otp.intaleqapp.com/api/request-otp.php';
|
$apiUrl = 'https://otp.intaleqapp.com/api/request-otp.php';
|
||||||
$payload = [
|
$payload = [
|
||||||
'phone' => $phoneWithPlus,
|
'phone' => $phoneWithPlus,
|
||||||
'app_key' => $appKey,
|
'app_key' => $appKey
|
||||||
'device_type' => 'android',
|
|
||||||
'method' => $method,
|
|
||||||
'code' => $otp
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = curlCall("POST", $apiUrl, json_encode($payload), [
|
$response = curlCall("POST", $apiUrl, json_encode($payload), [
|
||||||
@@ -199,6 +196,9 @@ function sendIntaleqOtp(string $receiver, string $otp, string $method = 'whatsap
|
|||||||
if ($response) {
|
if ($response) {
|
||||||
$decoded = json_decode($response, true);
|
$decoded = json_decode($response, true);
|
||||||
if ($decoded && ($decoded['success'] ?? false)) {
|
if ($decoded && ($decoded['success'] ?? false)) {
|
||||||
|
if (isset($decoded['otp'])) {
|
||||||
|
$otp = (string)$decoded['otp'];
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$msg = "❌ [Intaleq OTP] API returned failure response: " . $response;
|
$msg = "❌ [Intaleq OTP] API returned failure response: " . $response;
|
||||||
|
|||||||
@@ -44,6 +44,11 @@ class RateLimiter
|
|||||||
$this->redis->expire($key, $window);
|
$this->redis->expire($key, $window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Disable limit for register during debugging
|
||||||
|
if ($type === 'register') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return $current <= $max;
|
return $current <= $max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user