[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
This commit is contained in:
Vojtech Novak 2017-03-17 21:00:32 +01:00 committed by Joel Arvidsson
parent 0e350a9bfe
commit 33d1816272
1 changed files with 2 additions and 4 deletions

View File

@ -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