Update: 2026-06-23 18:12:45
This commit is contained in:
@@ -62,7 +62,7 @@ function getNabehBearerToken(): ?string {
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$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) {
|
||||
$msg = "⚠️ [Nabeh Auth] Missing NABEH_EMAIL or NABEH_PASSWORD environment variables.";
|
||||
error_log($msg); echo $msg . "<br>";
|
||||
error_log($msg);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -97,16 +97,16 @@ function getNabehBearerToken(): ?string {
|
||||
$redis->setex('nabeh_bearer_token', 86400, $token);
|
||||
} catch (Exception $e) {
|
||||
$msg = "⚠️ [Nabeh Auth Redis Cache Save] Error saving token: " . $e->getMessage();
|
||||
error_log($msg); echo $msg . "<br>";
|
||||
error_log($msg);
|
||||
}
|
||||
}
|
||||
return $token;
|
||||
}
|
||||
$msg = "❌ [Nabeh Auth] Failed to extract token from login response: " . $response;
|
||||
error_log($msg); echo $msg . "<br>";
|
||||
error_log($msg);
|
||||
} else {
|
||||
$msg = "❌ [Nabeh Auth] Empty response from login API cURL.";
|
||||
error_log($msg); echo $msg . "<br>";
|
||||
error_log($msg);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -123,7 +123,7 @@ function sendNabehOtp(string $receiver, string $otp, string $method = 'text'): b
|
||||
$bearerToken = getNabehBearerToken();
|
||||
if (!$bearerToken) {
|
||||
$msg = "⚠️ [Nabeh OTP] Failed to obtain dynamic JWT Bearer token.";
|
||||
error_log($msg); echo $msg . "<br>";
|
||||
error_log($msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -156,10 +156,10 @@ function sendNabehOtp(string $receiver, string $otp, string $method = 'text'): b
|
||||
return true;
|
||||
}
|
||||
$msg = "❌ [Nabeh OTP] API returned failure response: " . $response;
|
||||
error_log($msg); echo $msg . "<br>";
|
||||
error_log($msg);
|
||||
} else {
|
||||
$msg = "❌ [Nabeh OTP] Empty response from cURL.";
|
||||
error_log($msg); echo $msg . "<br>";
|
||||
error_log($msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -180,13 +180,9 @@ function sendIntaleqOtp(string $receiver, string $otp, string $method = 'whatsap
|
||||
return false;
|
||||
}
|
||||
|
||||
// Normalize receiver to start with +
|
||||
$phoneWithPlus = (strpos($receiver, '+') === 0) ? $receiver : '+' . $receiver;
|
||||
|
||||
$apiUrl = 'https://otp.intaleqapp.com/api/request-otp.php';
|
||||
$payload = [
|
||||
'phone' => $phoneWithPlus,
|
||||
'app_key' => $appKey,
|
||||
'phone' => $receiver,
|
||||
'device_type' => 'android',
|
||||
'method' => $method,
|
||||
'code' => $otp
|
||||
@@ -228,13 +224,13 @@ function curlCall(string $method, string $url, string $data, array $headers): ?s
|
||||
|
||||
if ($error) {
|
||||
$msg = "⚠️ [OTP cURL] Error calling $url: $error";
|
||||
error_log($msg); echo $msg . "<br>";
|
||||
error_log($msg);
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($httpCode !== 200) {
|
||||
$msg = "⚠️ [OTP cURL] Non-200 HTTP code $httpCode from $url. Response: $response";
|
||||
error_log($msg); echo $msg . "<br>";
|
||||
error_log($msg);
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
||||
@@ -27,7 +27,7 @@ try {
|
||||
$allowed1 = getenv('allowed1');
|
||||
$allowed2 = getenv('allowed2');
|
||||
$allowedAudiences = array_values(array_filter([$allowed1, $allowed2]));
|
||||
$passwordnewpassenger = getenv('passwordnewpassenger');
|
||||
$passwordnewpassenger = getenv('passwordnewpassenger') ?: '';
|
||||
|
||||
if (empty($id) || empty($password) || empty($audience)) {
|
||||
jsonError('Missing input fields.', 400);
|
||||
|
||||
@@ -250,6 +250,20 @@ SnackbarController? _show(_SnackVariant variant, String message) {
|
||||
try {
|
||||
// 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) {
|
||||
case HapticFeedbackType.light:
|
||||
HapticFeedback.lightImpact();
|
||||
@@ -259,27 +273,20 @@ SnackbarController? _show(_SnackVariant variant, String message) {
|
||||
HapticFeedback.selectionClick();
|
||||
}
|
||||
|
||||
return Get.snackbar(
|
||||
'',
|
||||
'',
|
||||
snackPosition: SnackPosition.TOP,
|
||||
backgroundColor: Colors.transparent,
|
||||
margin: EdgeInsets.zero,
|
||||
padding: EdgeInsets.zero,
|
||||
duration: const Duration(seconds: 4),
|
||||
animationDuration: const Duration(milliseconds: 380),
|
||||
barBlur: 0,
|
||||
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),
|
||||
messenger.showSnackBar(
|
||||
SnackBar(
|
||||
content: _SnackContent(message: message, variant: variant),
|
||||
backgroundColor: Colors.transparent,
|
||||
elevation: 0,
|
||||
margin: EdgeInsets.zero,
|
||||
padding: EdgeInsets.zero,
|
||||
behavior: SnackBarBehavior.floating,
|
||||
duration: const Duration(seconds: 4),
|
||||
dismissDirection: DismissDirection.up,
|
||||
),
|
||||
);
|
||||
|
||||
return null; // We return null since we no longer use Get.snackbar's controller
|
||||
} catch (e) {
|
||||
debugPrint("⚠️ Exception caught showing snackbar: $e");
|
||||
return null;
|
||||
|
||||
@@ -40,7 +40,7 @@ class GetQueue {
|
||||
var item = _queue.removeAt(0);
|
||||
try {
|
||||
item.completer.complete(await item.job());
|
||||
} on Exception catch (e) {
|
||||
} catch (e) {
|
||||
item.completer.completeError(e);
|
||||
}
|
||||
_active = false;
|
||||
|
||||
Reference in New Issue
Block a user