Update: 2026-06-26 02:29:35

This commit is contained in:
Hamza-Ayed
2026-06-26 02:29:35 +03:00
parent fe164a006b
commit f53177e715
3 changed files with 26 additions and 13 deletions

View File

@@ -4,7 +4,8 @@ import 'package:siro_service/constant/box_name.dart';
import 'package:siro_service/controller/functions/crud.dart';
import 'package:siro_service/main.dart';
import 'package:siro_service/print.dart';
import 'package:siro_service/controller/functions/encrypt_decrypt.dart';
import 'package:siro_service/env/env.dart';
/// مدير الجلسة - مسؤول عن مراقبة صلاحية الجلسة
/// وتجديدها تلقائياً عند انتهائها
class SessionManager extends GetxController {
@@ -28,12 +29,13 @@ class SessionManager extends GetxController {
/// التحقق من صلاحية الجلسة الحالية
SessionStatus checkSessionValidity() {
try {
final token = box.read(BoxName.jwt)?.toString() ?? '';
if (token.isEmpty) {
final rawToken = box.read(BoxName.jwt)?.toString() ?? '';
if (rawToken.isEmpty) {
status.value = SessionStatus.expired;
return SessionStatus.expired;
}
final token = r(rawToken).toString().split(Env.addd)[0];
final isValid = CRUD.isJwtValid(token);
if (!isValid) {
status.value = SessionStatus.expired;
@@ -58,7 +60,9 @@ class SessionManager extends GetxController {
await Future.delayed(const Duration(milliseconds: 500));
}
// نتحقق مرة أخرى بعد انتهاء التجديد
final isValid = CRUD.isJwtValid(box.read(BoxName.jwt)?.toString() ?? '');
final rawToken = box.read(BoxName.jwt)?.toString() ?? '';
final token = rawToken.isNotEmpty ? r(rawToken).toString().split(Env.addd)[0] : '';
final isValid = CRUD.isJwtValid(token);
return isValid;
}
@@ -78,7 +82,8 @@ class SessionManager extends GetxController {
await CRUD().getJWT();
// التحقق من نجاح التجديد
final newToken = box.read(BoxName.jwt)?.toString() ?? '';
final newRawToken = box.read(BoxName.jwt)?.toString() ?? '';
final newToken = newRawToken.isNotEmpty ? r(newRawToken).toString().split(Env.addd)[0] : '';
final isValid = CRUD.isJwtValid(newToken);
if (isValid) {