Update: 2026-07-09 17:18:06
This commit is contained in:
@@ -5,7 +5,6 @@ import 'package:crypto/crypto.dart';
|
||||
import 'dart:math';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:siro_driver/views/auth/captin/cards/sms_signup.dart';
|
||||
import 'package:siro_driver/views/auth/syria/registration_view.dart';
|
||||
import 'package:siro_driver/views/widgets/elevated_btn.dart';
|
||||
import 'package:siro_driver/views/widgets/error_snakbar.dart';
|
||||
@@ -173,18 +172,23 @@ class LoginDriverController extends GetxController {
|
||||
if (parts.length == 3) {
|
||||
var payload = parts[1];
|
||||
switch (payload.length % 4) {
|
||||
case 2: payload += '=='; break;
|
||||
case 3: payload += '='; break;
|
||||
case 2:
|
||||
payload += '==';
|
||||
break;
|
||||
case 3:
|
||||
payload += '=';
|
||||
break;
|
||||
}
|
||||
final decoded = jsonDecode(utf8.decode(base64Url.decode(payload)));
|
||||
final exp = decoded['exp'];
|
||||
if (exp != null) {
|
||||
// Check if token has at least 10 seconds remaining
|
||||
isTokenValid = DateTime.now().millisecondsSinceEpoch < (exp * 1000 - 10000);
|
||||
isTokenValid =
|
||||
DateTime.now().millisecondsSinceEpoch < (exp * 1000 - 10000);
|
||||
}
|
||||
}
|
||||
} catch (_) {}
|
||||
|
||||
|
||||
if (isTokenValid) {
|
||||
Log.print('🔑 Valid Wallet JWT found in storage. Skipping generation.');
|
||||
return cachedJwt;
|
||||
@@ -226,7 +230,7 @@ class LoginDriverController extends GetxController {
|
||||
|
||||
getJWT() async {
|
||||
await EncryptionHelper.initialize();
|
||||
|
||||
|
||||
// 1. Check secure storage first to avoid redundant API calls
|
||||
String? secureJwt = await storage.read(key: BoxName.jwt);
|
||||
if (secureJwt != null && secureJwt.isNotEmpty) {
|
||||
@@ -236,18 +240,23 @@ class LoginDriverController extends GetxController {
|
||||
if (parts.length == 3) {
|
||||
String payload = parts[1];
|
||||
switch (payload.length % 4) {
|
||||
case 2: payload += '=='; break;
|
||||
case 3: payload += '='; break;
|
||||
case 2:
|
||||
payload += '==';
|
||||
break;
|
||||
case 3:
|
||||
payload += '=';
|
||||
break;
|
||||
}
|
||||
final decoded = jsonDecode(utf8.decode(base64Url.decode(payload)));
|
||||
final exp = decoded['exp'];
|
||||
if (exp != null) {
|
||||
// Check if token is valid with a 30-second buffer
|
||||
isTokenValid = DateTime.now().millisecondsSinceEpoch < (exp * 1000 - 30000);
|
||||
isTokenValid =
|
||||
DateTime.now().millisecondsSinceEpoch < (exp * 1000 - 30000);
|
||||
}
|
||||
}
|
||||
} catch (_) {}
|
||||
|
||||
|
||||
if (isTokenValid) {
|
||||
Log.print('🔑 Valid JWT found in secure storage. Skipping generation.');
|
||||
return;
|
||||
|
||||
@@ -15,7 +15,7 @@ import '../../constant/colors.dart';
|
||||
import '../../constant/style.dart';
|
||||
import '../../main.dart';
|
||||
import '../../print.dart';
|
||||
import '../../views/auth/captin/criminal_documents_page.dart';
|
||||
import '../../views/auth/syria/registration_view.dart';
|
||||
import '../../views/home/Captin/home_captain/home_captin.dart';
|
||||
import '../../views/home/Captin/orderCaptin/order_request_page.dart';
|
||||
import '../../views/home/Captin/orderCaptin/vip_order_page.dart';
|
||||
@@ -263,7 +263,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
notificationController.showNotification(title, body, 'tone2', '');
|
||||
}
|
||||
MyDialog().getDialog(title, 'You should have upload it .'.tr, () {
|
||||
Get.to(() => const CriminalDocumemtPage());
|
||||
Get.to(() => const RegistrationView());
|
||||
});
|
||||
break;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import 'package:siro_driver/views/widgets/elevated_btn.dart';
|
||||
|
||||
import '../../constant/box_name.dart';
|
||||
import '../../constant/links.dart';
|
||||
import '../auth/captin/register_captin_controller.dart';
|
||||
import '../auth/syria/registration_controller.dart';
|
||||
import 'launch.dart';
|
||||
|
||||
//
|
||||
@@ -466,11 +466,10 @@ class ScanDocumentsByApi extends GetxController {
|
||||
: MyElevatedButton(
|
||||
title: 'Next'.tr,
|
||||
onPressed: () async {
|
||||
RegisterCaptainController registerCaptainController =
|
||||
Get.put(RegisterCaptainController());
|
||||
RegistrationController registrationController =
|
||||
Get.put(RegistrationController());
|
||||
|
||||
await registerCaptainController.register();
|
||||
await registerCaptainController.addLisence();
|
||||
await registrationController.submitRegistration();
|
||||
await uploadImagePortrate();
|
||||
// Get.to(() => CarLicensePage());
|
||||
},
|
||||
@@ -557,10 +556,12 @@ class ScanDocumentsByApi extends GetxController {
|
||||
if (responseString.isNotEmpty) {
|
||||
try {
|
||||
final decoded = jsonDecode(responseString);
|
||||
if (decoded['status'] == 'success' && decoded['message']['file_link'] != null) {
|
||||
if (decoded['status'] == 'success' &&
|
||||
decoded['message']['file_link'] != null) {
|
||||
String rawUrl = decoded['message']['file_link'].toString();
|
||||
String filename = rawUrl.split('/').last;
|
||||
box.write(BoxName.driverPhotoUrl, '${AppLink.server}/portrate_captain_image/$filename');
|
||||
box.write(BoxName.driverPhotoUrl,
|
||||
'${AppLink.server}/portrate_captain_image/$filename');
|
||||
}
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:siro_driver/constant/api_key.dart';
|
||||
import 'package:siro_driver/constant/box_name.dart';
|
||||
import 'package:siro_driver/constant/info.dart';
|
||||
import 'package:siro_driver/constant/links.dart';
|
||||
import 'package:siro_driver/controller/auth/captin/register_captin_controller.dart';
|
||||
import 'package:siro_driver/controller/auth/syria/registration_controller.dart';
|
||||
import 'package:siro_driver/controller/functions/crud.dart';
|
||||
import 'package:siro_driver/main.dart';
|
||||
import 'package:siro_driver/views/widgets/elevated_btn.dart';
|
||||
@@ -40,10 +40,10 @@ class SmsEgyptController extends GetxController {
|
||||
if (jsonDecode(res.body)['message'].toString() != "Success") {
|
||||
await CRUD().post(link: AppLink.updatePhoneInvalidSMS, payload: {
|
||||
"phone_number":
|
||||
('+2${Get.find<RegisterCaptainController>().phoneController.text}')
|
||||
('+2${Get.find<RegistrationController>().phoneController.text}')
|
||||
});
|
||||
box.write(BoxName.phoneDriver,
|
||||
('+2${Get.find<RegisterCaptainController>().phoneController.text}'));
|
||||
('+2${Get.find<RegistrationController>().phoneController.text}'));
|
||||
box.write(BoxName.phoneVerified, '1');
|
||||
|
||||
await Get.put(LoginDriverController()).loginDriver(
|
||||
|
||||
Reference in New Issue
Block a user