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

View File

@@ -30,7 +30,7 @@ class CaptchaWidgetLogic extends GetxController with StateMixin<CaptchaResponseM
change(null, status: RxStatus.loading()); change(null, status: RxStatus.loading());
textController.value.clear(); textController.value.clear();
await Future.delayed(Duration(milliseconds: 800)); 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()); change(value, status: RxStatus.success());
} }