From cadc35ea8fd9a0ee8ad4f5ada445e4dcfa99b425 Mon Sep 17 00:00:00 2001 From: Erick Date: Thu, 3 Oct 2024 15:46:29 +0300 Subject: [PATCH] fix: local auth requiring password even on desktop and web --- lib/controllers/controller_ready_mixin.dart | 21 ------------- lib/controllers/controllers.dart | 1 - lib/controllers/settings_controller.dart | 33 +++++++++++---------- 3 files changed, 18 insertions(+), 37 deletions(-) delete mode 100644 lib/controllers/controller_ready_mixin.dart diff --git a/lib/controllers/controller_ready_mixin.dart b/lib/controllers/controller_ready_mixin.dart deleted file mode 100644 index 55a45ad..0000000 --- a/lib/controllers/controller_ready_mixin.dart +++ /dev/null @@ -1,21 +0,0 @@ -import 'dart:async'; -import 'package:get/get.dart'; - -mixin ReadyMixin on GetxController { - final isControllerReady = false.obs; - FutureOr initController(); - FutureOr controllerReady() {} - - @override - void onInit() async { - await initController(); - super.onInit(); - } - - @override - void onReady() async { - await controllerReady(); - super.onReady(); - isControllerReady.value = true; - } -} diff --git a/lib/controllers/controllers.dart b/lib/controllers/controllers.dart index c02f843..24dcc93 100644 --- a/lib/controllers/controllers.dart +++ b/lib/controllers/controllers.dart @@ -4,4 +4,3 @@ export 'network_controller.dart'; export 'reward_controller.dart'; export 'settings_controller.dart'; export 'notifications_controller.dart'; -export 'controller_ready_mixin.dart'; diff --git a/lib/controllers/settings_controller.dart b/lib/controllers/settings_controller.dart index 56aa7ed..3534fea 100644 --- a/lib/controllers/settings_controller.dart +++ b/lib/controllers/settings_controller.dart @@ -31,22 +31,25 @@ class SettingsController extends GetxController with StateMixin { Future performLocalAuthentication(String reason) async { bool authenticated = false; - try { - authenticated = await localAuthentication.authenticate( - localizedReason: reason, - options: const AuthenticationOptions( - stickyAuth: true, - sensitiveTransaction: true, - ), - ); - } on PlatformException catch (e) { - authenticated = false; - debugPrint(e.toString()); - } catch (e) { - debugPrint(e.toString()); - } + if (Platform.isIOS || Platform.isAndroid) { + try { + authenticated = await localAuthentication.authenticate( + localizedReason: reason, + options: const AuthenticationOptions( + stickyAuth: true, + sensitiveTransaction: true, + ), + ); + } on PlatformException catch (e) { + authenticated = false; + debugPrint(e.toString()); + } catch (e) { + debugPrint(e.toString()); + } - return authenticated; + return authenticated; + } + return true; } Future deviceSupportsLocalAuth() async {