Update: 2026-06-23 18:12:45
This commit is contained in:
@@ -62,7 +62,7 @@ function getNabehBearerToken(): ?string {
|
|||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$msg = "⚠️ [Nabeh Auth Redis] Error reading token: " . $e->getMessage();
|
$msg = "⚠️ [Nabeh Auth Redis] Error reading token: " . $e->getMessage();
|
||||||
error_log($msg); echo $msg . "<br>";
|
error_log($msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ function getNabehBearerToken(): ?string {
|
|||||||
|
|
||||||
if (!$email || !$password) {
|
if (!$email || !$password) {
|
||||||
$msg = "⚠️ [Nabeh Auth] Missing NABEH_EMAIL or NABEH_PASSWORD environment variables.";
|
$msg = "⚠️ [Nabeh Auth] Missing NABEH_EMAIL or NABEH_PASSWORD environment variables.";
|
||||||
error_log($msg); echo $msg . "<br>";
|
error_log($msg);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,16 +97,16 @@ function getNabehBearerToken(): ?string {
|
|||||||
$redis->setex('nabeh_bearer_token', 86400, $token);
|
$redis->setex('nabeh_bearer_token', 86400, $token);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$msg = "⚠️ [Nabeh Auth Redis Cache Save] Error saving token: " . $e->getMessage();
|
$msg = "⚠️ [Nabeh Auth Redis Cache Save] Error saving token: " . $e->getMessage();
|
||||||
error_log($msg); echo $msg . "<br>";
|
error_log($msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $token;
|
return $token;
|
||||||
}
|
}
|
||||||
$msg = "❌ [Nabeh Auth] Failed to extract token from login response: " . $response;
|
$msg = "❌ [Nabeh Auth] Failed to extract token from login response: " . $response;
|
||||||
error_log($msg); echo $msg . "<br>";
|
error_log($msg);
|
||||||
} else {
|
} else {
|
||||||
$msg = "❌ [Nabeh Auth] Empty response from login API cURL.";
|
$msg = "❌ [Nabeh Auth] Empty response from login API cURL.";
|
||||||
error_log($msg); echo $msg . "<br>";
|
error_log($msg);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,7 @@ function sendNabehOtp(string $receiver, string $otp, string $method = 'text'): b
|
|||||||
$bearerToken = getNabehBearerToken();
|
$bearerToken = getNabehBearerToken();
|
||||||
if (!$bearerToken) {
|
if (!$bearerToken) {
|
||||||
$msg = "⚠️ [Nabeh OTP] Failed to obtain dynamic JWT Bearer token.";
|
$msg = "⚠️ [Nabeh OTP] Failed to obtain dynamic JWT Bearer token.";
|
||||||
error_log($msg); echo $msg . "<br>";
|
error_log($msg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,10 +156,10 @@ function sendNabehOtp(string $receiver, string $otp, string $method = 'text'): b
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$msg = "❌ [Nabeh OTP] API returned failure response: " . $response;
|
$msg = "❌ [Nabeh OTP] API returned failure response: " . $response;
|
||||||
error_log($msg); echo $msg . "<br>";
|
error_log($msg);
|
||||||
} else {
|
} else {
|
||||||
$msg = "❌ [Nabeh OTP] Empty response from cURL.";
|
$msg = "❌ [Nabeh OTP] Empty response from cURL.";
|
||||||
error_log($msg); echo $msg . "<br>";
|
error_log($msg);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -180,13 +180,9 @@ function sendIntaleqOtp(string $receiver, string $otp, string $method = 'whatsap
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normalize receiver to start with +
|
|
||||||
$phoneWithPlus = (strpos($receiver, '+') === 0) ? $receiver : '+' . $receiver;
|
|
||||||
|
|
||||||
$apiUrl = 'https://otp.intaleqapp.com/api/request-otp.php';
|
$apiUrl = 'https://otp.intaleqapp.com/api/request-otp.php';
|
||||||
$payload = [
|
$payload = [
|
||||||
'phone' => $phoneWithPlus,
|
'phone' => $receiver,
|
||||||
'app_key' => $appKey,
|
|
||||||
'device_type' => 'android',
|
'device_type' => 'android',
|
||||||
'method' => $method,
|
'method' => $method,
|
||||||
'code' => $otp
|
'code' => $otp
|
||||||
@@ -228,13 +224,13 @@ function curlCall(string $method, string $url, string $data, array $headers): ?s
|
|||||||
|
|
||||||
if ($error) {
|
if ($error) {
|
||||||
$msg = "⚠️ [OTP cURL] Error calling $url: $error";
|
$msg = "⚠️ [OTP cURL] Error calling $url: $error";
|
||||||
error_log($msg); echo $msg . "<br>";
|
error_log($msg);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($httpCode !== 200) {
|
if ($httpCode !== 200) {
|
||||||
$msg = "⚠️ [OTP cURL] Non-200 HTTP code $httpCode from $url. Response: $response";
|
$msg = "⚠️ [OTP cURL] Non-200 HTTP code $httpCode from $url. Response: $response";
|
||||||
error_log($msg); echo $msg . "<br>";
|
error_log($msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ try {
|
|||||||
$allowed1 = getenv('allowed1');
|
$allowed1 = getenv('allowed1');
|
||||||
$allowed2 = getenv('allowed2');
|
$allowed2 = getenv('allowed2');
|
||||||
$allowedAudiences = array_values(array_filter([$allowed1, $allowed2]));
|
$allowedAudiences = array_values(array_filter([$allowed1, $allowed2]));
|
||||||
$passwordnewpassenger = getenv('passwordnewpassenger');
|
$passwordnewpassenger = getenv('passwordnewpassenger') ?: '';
|
||||||
|
|
||||||
if (empty($id) || empty($password) || empty($audience)) {
|
if (empty($id) || empty($password) || empty($audience)) {
|
||||||
jsonError('Missing input fields.', 400);
|
jsonError('Missing input fields.', 400);
|
||||||
|
|||||||
@@ -250,6 +250,20 @@ SnackbarController? _show(_SnackVariant variant, String message) {
|
|||||||
try {
|
try {
|
||||||
// Removed Get.closeCurrentSnackbar() because it causes async LateInitializationError in GetX at early startup
|
// Removed Get.closeCurrentSnackbar() because it causes async LateInitializationError in GetX at early startup
|
||||||
|
|
||||||
|
// We use ScaffoldMessenger instead of Get.snackbar because GetX's snackbar
|
||||||
|
// throws synchronous "No Overlay widget found" FlutterErrors when the
|
||||||
|
// Overlay isn't perfectly mounted, crashing the app globally.
|
||||||
|
final context = Get.context;
|
||||||
|
if (context == null) return null;
|
||||||
|
|
||||||
|
final messenger = ScaffoldMessenger.maybeOf(context);
|
||||||
|
if (messenger == null) {
|
||||||
|
debugPrint("⚠️ Cannot show snackbar: ScaffoldMessenger not found. Message: $message");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
messenger.clearSnackBars(); // Prevent stacking
|
||||||
|
|
||||||
switch (variant.haptic) {
|
switch (variant.haptic) {
|
||||||
case HapticFeedbackType.light:
|
case HapticFeedbackType.light:
|
||||||
HapticFeedback.lightImpact();
|
HapticFeedback.lightImpact();
|
||||||
@@ -259,27 +273,20 @@ SnackbarController? _show(_SnackVariant variant, String message) {
|
|||||||
HapticFeedback.selectionClick();
|
HapticFeedback.selectionClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Get.snackbar(
|
messenger.showSnackBar(
|
||||||
'',
|
SnackBar(
|
||||||
'',
|
content: _SnackContent(message: message, variant: variant),
|
||||||
snackPosition: SnackPosition.TOP,
|
backgroundColor: Colors.transparent,
|
||||||
backgroundColor: Colors.transparent,
|
elevation: 0,
|
||||||
margin: EdgeInsets.zero,
|
margin: EdgeInsets.zero,
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
duration: const Duration(seconds: 4),
|
behavior: SnackBarBehavior.floating,
|
||||||
animationDuration: const Duration(milliseconds: 380),
|
duration: const Duration(seconds: 4),
|
||||||
barBlur: 0,
|
dismissDirection: DismissDirection.up,
|
||||||
overlayBlur: 0,
|
|
||||||
overlayColor: Colors.transparent,
|
|
||||||
isDismissible: true,
|
|
||||||
dismissDirection: DismissDirection.up,
|
|
||||||
forwardAnimationCurve: Curves.easeOutCubic,
|
|
||||||
reverseAnimationCurve: Curves.easeInCubic,
|
|
||||||
snackStyle: SnackStyle.FLOATING,
|
|
||||||
userInputForm: Form(
|
|
||||||
child: _SnackContent(message: message, variant: variant),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return null; // We return null since we no longer use Get.snackbar's controller
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugPrint("⚠️ Exception caught showing snackbar: $e");
|
debugPrint("⚠️ Exception caught showing snackbar: $e");
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class GetQueue {
|
|||||||
var item = _queue.removeAt(0);
|
var item = _queue.removeAt(0);
|
||||||
try {
|
try {
|
||||||
item.completer.complete(await item.job());
|
item.completer.complete(await item.job());
|
||||||
} on Exception catch (e) {
|
} catch (e) {
|
||||||
item.completer.completeError(e);
|
item.completer.completeError(e);
|
||||||
}
|
}
|
||||||
_active = false;
|
_active = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user