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