From 33d18162726842956dd238040e87433a52017947 Mon Sep 17 00:00:00 2001 From: Vojtech Novak Date: Fri, 17 Mar 2017 21:00:32 +0100 Subject: [PATCH] [android] return false instead of exception when entry not present (#57) * Update KeychainModule.java this will return false when a keychain entry is not present, so it'll behave same as on ios * do not throw on entry reset --- .../src/main/java/com/oblador/keychain/KeychainModule.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/android/src/main/java/com/oblador/keychain/KeychainModule.java b/android/src/main/java/com/oblador/keychain/KeychainModule.java index df07178..85c2735 100644 --- a/android/src/main/java/com/oblador/keychain/KeychainModule.java +++ b/android/src/main/java/com/oblador/keychain/KeychainModule.java @@ -92,7 +92,7 @@ public class KeychainModule extends ReactContextBaseJavaModule { String password = prefs.getString(service + ":p", "pass_not_found"); if (username.equals("user_not_found") || password.equals("pass_not_found")) { Log.e(KEYCHAIN_MODULE, "no keychain entry found for service: " + service); - promise.reject("no keychain entry found for service: " + service); + promise.resolve(false); return; } @@ -128,10 +128,8 @@ public class KeychainModule extends ReactContextBaseJavaModule { prefsEditor.remove(service + ":u"); prefsEditor.remove(service + ":p"); prefsEditor.apply(); - promise.resolve("KeychainModule password was reset"); - } else { - promise.reject("Error when resetting password: entry not found for service: " + service); } + promise.resolve(true); } @ReactMethod