diff --git a/backend/auth/otp/providers.php b/backend/auth/otp/providers.php index ee10320..5a611ec 100644 --- a/backend/auth/otp/providers.php +++ b/backend/auth/otp/providers.php @@ -62,7 +62,7 @@ function getNabehBearerToken(): ?string { } } catch (Exception $e) { $msg = "⚠️ [Nabeh Auth Redis] Error reading token: " . $e->getMessage(); - error_log($msg); echo $msg . "
"; + 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 . "
"; + 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 . "
"; + error_log($msg); } } return $token; } $msg = "❌ [Nabeh Auth] Failed to extract token from login response: " . $response; - error_log($msg); echo $msg . "
"; + error_log($msg); } else { $msg = "❌ [Nabeh Auth] Empty response from login API cURL."; - error_log($msg); echo $msg . "
"; + 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 . "
"; + 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 . "
"; + error_log($msg); } else { $msg = "❌ [Nabeh OTP] Empty response from cURL."; - error_log($msg); echo $msg . "
"; + 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 . "
"; + 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 . "
"; + error_log($msg); } return $response; diff --git a/backend/loginFirstTime.php b/backend/loginFirstTime.php index 5ef4248..a036ee4 100644 --- a/backend/loginFirstTime.php +++ b/backend/loginFirstTime.php @@ -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); diff --git a/siro_rider/lib/views/widgets/error_snakbar.dart b/siro_rider/lib/views/widgets/error_snakbar.dart index b4ee521..cb141e3 100644 --- a/siro_rider/lib/views/widgets/error_snakbar.dart +++ b/siro_rider/lib/views/widgets/error_snakbar.dart @@ -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; diff --git a/siro_rider/packages/get/lib/get_utils/src/queue/get_queue.dart b/siro_rider/packages/get/lib/get_utils/src/queue/get_queue.dart index 25e78bd..de62b14 100644 --- a/siro_rider/packages/get/lib/get_utils/src/queue/get_queue.dart +++ b/siro_rider/packages/get/lib/get_utils/src/queue/get_queue.dart @@ -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;