Update: 2026-06-12 22:40:40
This commit is contained in:
@@ -4,12 +4,9 @@ import 'package:siro_rider/constant/box_name.dart';
|
||||
import 'package:siro_rider/constant/info.dart';
|
||||
import 'package:siro_rider/controller/auth/login_controller.dart';
|
||||
import 'package:jwt_decoder/jwt_decoder.dart';
|
||||
import 'package:secure_string_operations/secure_string_operations.dart';
|
||||
|
||||
import '../../constant/char_map.dart';
|
||||
import '../../constant/links.dart';
|
||||
import '../../main.dart';
|
||||
import '../../print.dart';
|
||||
import 'crud.dart';
|
||||
import 'encrypt_decrypt.dart';
|
||||
|
||||
@@ -24,23 +21,25 @@ class SecureStorage {
|
||||
}
|
||||
}
|
||||
|
||||
const List<String> keysToFetch = [
|
||||
'serverPHP',
|
||||
// 'seferAlexandriaServer',
|
||||
// 'seferPaymentServer',
|
||||
// 'seferCairoServer',
|
||||
// 'seferGizaServer',
|
||||
];
|
||||
|
||||
class AppInitializer {
|
||||
List<Map<String, dynamic>> links = [];
|
||||
|
||||
/// تقرأ JWT من FlutterSecureStorage أولاً، مع fallback إلى GetStorage
|
||||
Future<String?> _readJwt() async {
|
||||
try {
|
||||
final secureJwt = await storage.read(key: 'jwt');
|
||||
if (secureJwt != null && secureJwt.isNotEmpty) return secureJwt;
|
||||
} catch (_) {}
|
||||
return box.read(BoxName.jwt);
|
||||
}
|
||||
|
||||
Future<void> initializeApp() async {
|
||||
if (box.read(BoxName.jwt) == null) {
|
||||
final jwt = await _readJwt();
|
||||
if (jwt == null) {
|
||||
await LoginController().getJWT();
|
||||
} else {
|
||||
bool isTokenExpired = JwtDecoder.isExpired(
|
||||
r(box.read(BoxName.jwt)).toString().split(AppInformation.addd)[0]);
|
||||
bool isTokenExpired =
|
||||
JwtDecoder.isExpired(r(jwt).toString().split(AppInformation.addd)[0]);
|
||||
|
||||
if (isTokenExpired) {
|
||||
await LoginController().getJWT();
|
||||
|
||||
Reference in New Issue
Block a user