Update KeychainModule.java

This commit is contained in:
Vojtech Novak 2016-12-11 16:30:50 +01:00 committed by GitHub
parent e335c69ce9
commit 7e3b8642bd
1 changed files with 4 additions and 5 deletions

View File

@ -118,16 +118,15 @@ public class KeychainModule extends ReactContextBaseJavaModule {
@ReactMethod
public void resetGenericPasswordForService(String service, Callback callback) {
service = service == null ? "" : service;
try {
SharedPreferences.Editor prefsEditor = prefs.edit();
if (prefs.contains(service + ":u")) {
prefsEditor.remove(service + ":u");
prefsEditor.remove(service + ":p");
prefsEditor.apply();
callback.invoke("", "KeychainModule password was reset");
} catch (Exception e) {
//this probably never happens but it is here so that the android api is the same as on iOS
callback.invoke(e.getLocalizedMessage());
} else {
callback.invoke("Error when resetting password: entry not found for service: " + service);
}
}