YADESK-623 update state on password operations

This commit is contained in:
Adam Velebil 2022-04-07 08:32:11 +02:00
parent 2222f2536a
commit 4a0014292d
No known key found for this signature in database
GPG Key ID: AC6D6B9D715FC084

View File

@ -55,7 +55,10 @@ class _AndroidOathStateNotifier extends OathStateNotifier {
if (unlocked) { if (unlocked) {
_log.config('applet unlocked'); _log.config('applet unlocked');
setData(state.value!.copyWith(locked: false)); setData(state.value!.copyWith(
locked: false,
remembered: remembered,
));
} }
return Pair(unlocked, remembered); return Pair(unlocked, remembered);
} on PlatformException catch (e) { } on PlatformException catch (e) {
@ -68,6 +71,7 @@ class _AndroidOathStateNotifier extends OathStateNotifier {
Future<bool> setPassword(String? current, String password) async { Future<bool> setPassword(String? current, String password) async {
try { try {
await _api.setPassword(current, password); await _api.setPassword(current, password);
setData(state.value!.copyWith(hasKey: true));
return true; return true;
} on PlatformException catch (e) { } on PlatformException catch (e) {
_log.config('Calling set password failed with exception: $e'); _log.config('Calling set password failed with exception: $e');
@ -79,6 +83,7 @@ class _AndroidOathStateNotifier extends OathStateNotifier {
Future<bool> unsetPassword(String current) async { Future<bool> unsetPassword(String current) async {
try { try {
await _api.unsetPassword(current); await _api.unsetPassword(current);
setData(state.value!.copyWith(hasKey: false, locked: false));
return true; return true;
} on PlatformException catch (e) { } on PlatformException catch (e) {
_log.config('Calling unset password failed with exception: $e'); _log.config('Calling unset password failed with exception: $e');
@ -90,6 +95,7 @@ class _AndroidOathStateNotifier extends OathStateNotifier {
Future<void> forgetPassword() async { Future<void> forgetPassword() async {
try { try {
await _api.forgetPassword(); await _api.forgetPassword();
setData(state.value!.copyWith(remembered: false));
} on PlatformException catch (e) { } on PlatformException catch (e) {
_log.config('Calling forgetPassword failed with exception: $e'); _log.config('Calling forgetPassword failed with exception: $e');
} }