feat : change app inspector and exception handling
This commit is contained in:
@@ -9,7 +9,7 @@ import '../common/dio_manager.dart';
|
||||
GetIt diAuth = GetIt.instance;
|
||||
|
||||
Future<void> setupAuthDI() async {
|
||||
diAuth.registerLazySingleton(() => DioRemoteManager());
|
||||
|
||||
diAuth.registerLazySingleton<AppInterceptor>(
|
||||
() => AppInterceptor(
|
||||
refreshTokenCallback: () async {
|
||||
@@ -19,7 +19,9 @@ Future<void> setupAuthDI() async {
|
||||
final refreshToken = tokenService.refreshToken.value;
|
||||
if (refreshToken == null) return null;
|
||||
|
||||
final result = await authRepo.loginWithRefreshToken(authRequest: {"refresh_token": refreshToken});
|
||||
final result = await authRepo.loginWithRefreshToken(
|
||||
authRequest: {"refresh_token": refreshToken},
|
||||
);
|
||||
|
||||
if (result is AuthResponseModel) {
|
||||
await tokenService.saveAccessToken(result.access!);
|
||||
@@ -27,10 +29,18 @@ Future<void> setupAuthDI() async {
|
||||
}
|
||||
return null;
|
||||
},
|
||||
saveTokenCallback: (String newToken) async {
|
||||
//
|
||||
},
|
||||
clearTokenCallback: () async {
|
||||
//await tokenService.clearTokens(); // حذف همه توکنها
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
diAuth.registerLazySingleton<DioRemote>(() => DioRemote(interceptors: [diAuth.get<AppInterceptor>()]));
|
||||
diAuth.registerLazySingleton<DioRemote>(
|
||||
() => DioRemote(interceptors: diAuth.get<AppInterceptor>()),
|
||||
);
|
||||
|
||||
final dioRemote = diAuth.get<DioRemote>();
|
||||
await dioRemote.init();
|
||||
@@ -40,10 +50,13 @@ Future<void> setupAuthDI() async {
|
||||
|
||||
Future<void> newSetupAuthDI(String newUrl) async {
|
||||
diAuth.registerLazySingleton<DioRemote>(
|
||||
() => DioRemote(baseUrl: newUrl, interceptors: [diAuth.get<AppInterceptor>()]),
|
||||
() => DioRemote(baseUrl: newUrl, interceptors: diAuth.get<AppInterceptor>()),
|
||||
instanceName: 'newRemote',
|
||||
);
|
||||
final dioRemote = diAuth.get<DioRemote>(instanceName: 'newRemote');
|
||||
await dioRemote.init();
|
||||
diAuth.registerSingleton<AuthRepositoryImpl>(AuthRepositoryImpl(dioRemote), instanceName: 'newUrl');
|
||||
diAuth.registerSingleton<AuthRepositoryImpl>(
|
||||
AuthRepositoryImpl(dioRemote),
|
||||
instanceName: 'newUrl',
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user