fix : login api call
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
class UserEntity {
|
||||
String? token;
|
||||
String? refreshToken;
|
||||
|
||||
UserEntity({this.token, this.refreshToken});
|
||||
}
|
||||
@@ -6,7 +6,7 @@ final di = GetIt.instance;
|
||||
|
||||
Future<void> setupInjection() async{
|
||||
await setupAuthDI();
|
||||
await setupAllProvider();
|
||||
await setupAllCoreProvider();
|
||||
|
||||
}
|
||||
|
||||
|
||||
34
lib/infrastructure/service/auth_service.dart
Normal file
34
lib/infrastructure/service/auth_service.dart
Normal 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}');
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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(),));
|
||||
|
||||
Reference in New Issue
Block a user