[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:
parent
0e350a9bfe
commit
33d1816272
|
@ -92,7 +92,7 @@ public class KeychainModule extends ReactContextBaseJavaModule {
|
||||||
String password = prefs.getString(service + ":p", "pass_not_found");
|
String password = prefs.getString(service + ":p", "pass_not_found");
|
||||||
if (username.equals("user_not_found") || password.equals("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);
|
Log.e(KEYCHAIN_MODULE, "no keychain entry found for service: " + service);
|
||||||
promise.reject("no keychain entry found for service: " + service);
|
promise.resolve(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,10 +128,8 @@ public class KeychainModule extends ReactContextBaseJavaModule {
|
||||||
prefsEditor.remove(service + ":u");
|
prefsEditor.remove(service + ":u");
|
||||||
prefsEditor.remove(service + ":p");
|
prefsEditor.remove(service + ":p");
|
||||||
prefsEditor.apply();
|
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
|
@ReactMethod
|
||||||
|
|
Loading…
Reference in New Issue