fix : auth

This commit is contained in:
MrM
2025-06-03 23:57:25 +03:30
parent 151fa10641
commit 5849466e3b
3 changed files with 15 additions and 11 deletions

View File

@@ -16,9 +16,16 @@ Future<void> setupAuthDI() async {
final dioRemote = diAuth.get<DioRemote>();
await dioRemote.init();
diAuth.registerCachedFactory<AuthRepositoryImpl>(
() => AuthRepositoryImpl(dioRemote),
);
diAuth.registerSingleton<AuthRepositoryImpl>(AuthRepositoryImpl(dioRemote));
diAuth.registerLazySingleton<DioErrorHandler>(() => DioErrorHandler());
}
Future<void> newSetupAuthDI(String newUrl) async {
diAuth.registerLazySingleton<DioRemote>(() => DioRemote(baseUrl: newUrl),instanceName: 'newRemote');
final dioRemote = diAuth.get<DioRemote>(instanceName: 'newRemote');
await dioRemote.init();
diAuth.registerSingleton<AuthRepositoryImpl>(
AuthRepositoryImpl(dioRemote),
instanceName: 'newUrl',
);
}

View File

@@ -135,10 +135,10 @@ class AuthLogic extends GetxController {
Future<void> submitLoginForm2() async {
if (!_isFormValid()) return;
AuthRepositoryImpl authTmp = diAuth.get<AuthRepositoryImpl>(instanceName: 'newUrl');
isLoading.value = true;
await safeCall<UserProfileModel?>(
call: () => authRepository.login(
call: () => authTmp.login(
authRequest: {
"username": phoneNumberController.value.text,
"password": passwordController.value.text,
@@ -165,10 +165,7 @@ class AuthLogic extends GetxController {
call: () async => await authRepository.getUserInfo(value),
onSuccess: (result) async {
if (result != null) {
diAuth.registerSingleton<DioRemote>(
DioRemote(baseUrl: result.backend),
instanceName: 'newDioRemote',
);
await newSetupAuthDI(result.backend ?? '');
await tokenStorageService.saveApiKey(result.apiKey ?? '');
await tokenStorageService.saveBaseUrl(result.backend ?? '');
}

View File

@@ -30,7 +30,7 @@ class CaptchaWidgetLogic extends GetxController with StateMixin<CaptchaResponseM
change(null, status: RxStatus.loading());
textController.value.clear();
await Future.delayed(Duration(milliseconds: 800));
captchaKey.value = (random.nextInt(999999)+1000).toString();
captchaKey.value = (random.nextInt(999999)+100000).toString();
change(value, status: RxStatus.success());
}