fix : login api call

This commit is contained in:
2025-05-17 17:07:44 +03:30
parent 303ff86d85
commit 6843973c4f
12 changed files with 180 additions and 130 deletions

View File

@@ -1,6 +0,0 @@
class UserEntity {
String? token;
String? refreshToken;
UserEntity({this.token, this.refreshToken});
}

View File

@@ -6,7 +6,7 @@ final di = GetIt.instance;
Future<void> setupInjection() async{
await setupAuthDI();
await setupAllProvider();
await setupAllCoreProvider();
}

View File

@@ -0,0 +1,34 @@
import 'package:rasadyar_auth/auth.dart';
import 'package:rasadyar_auth/data/services/token_storage_service.dart';
import 'package:rasadyar_core/core.dart';
class AuthService extends GetxService {
var tokenService = diAuth.get<TokenStorageService>();
RxBool accessRes = false.obs;
RxBool refAccessRes = false.obs;
@override
void onInit() {
super.onInit();
ever(tokenService.accessToken, (callback) {
iLog('Access token callback: $callback, value: ${tokenService.accessToken.value}');
accessRes.value = (callback != null);
});
// رصد تغییرات refreshToken
ever(tokenService.refreshToken, (callback) {
fLog('Refresh token callback: $callback, value: ${tokenService.refreshToken.value}');
refAccessRes.value = (callback != null);
});
// بررسی اینکه هر دو مقدار دارند
everAll([accessRes, refAccessRes], (_) {
if (accessRes.value && refAccessRes.value) {
fLog('Both accessToken and refreshToken are available: accessToken=${tokenService.accessToken.value}, refreshToken=${tokenService.refreshToken.value}');
} else {
fLog('One or both tokens are missing: accessToken=${tokenService.accessToken.value}, refreshToken=${tokenService.refreshToken.value}');
}
});
}
}

View File

@@ -1,12 +1,15 @@
import 'package:flutter/material.dart';
import 'package:rasadyar_app/presentation/routes/app_pages.dart';
import 'package:rasadyar_core/core.dart';
import 'infrastructure/di/di.dart';
import 'infrastructure/service/auth_service.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await setupInjection();
Get.put(AuthService());
runApp(MyApp());
// runApp(DevicePreview(builder: (context) => ForDevicePreview(),));