Use LoginWithConfig method to log in (#13414)

This commit is contained in:
frank 2022-06-09 20:42:36 +08:00 committed by GitHub
parent cc2b6ab80c
commit 51174f8488
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 2 deletions

View File

@ -370,6 +370,18 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
}
}
@ReactMethod
public void loginWithConfig(final String accountData, final String password, final String configJSON) {
Log.d(TAG, "loginWithConfig");
this.migrateKeyStoreDir(accountData, password);
String result = Statusgo.loginWithConfig(accountData, password, configJSON);
if (result.startsWith("{\"error\":\"\"")) {
Log.d(TAG, "LoginWithConfig result: " + result);
} else {
Log.e(TAG, "LoginWithConfig failed: " + result);
}
}
@ReactMethod
public void exportUnencryptedDatabase(final String accountData, final String password, final Callback callback) {
Log.d(TAG, "login");

View File

@ -542,6 +542,19 @@ RCT_EXPORT_METHOD(login:(NSString *)accountData
NSLog(@"%@", result);
}
//////////////////////////////////////////////////////////////////// loginWithConfig
RCT_EXPORT_METHOD(loginWithConfig:(NSString *)accountData
password:(NSString *)password
configJSON:(NSString *)configJSON) {
#if DEBUG
NSLog(@"LoginWithConfig() method called");
#endif
[self getExportDbFilePath];
[self migrateKeystore:accountData password:password];
NSString *result = StatusgoLoginWithConfig(accountData, password, configJSON);
NSLog(@"%@", result);
}
//////////////////////////////////////////////////////////////////// loginWithKeycard
RCT_EXPORT_METHOD(loginWithKeycard:(NSString *)accountData
password:(NSString *)password

View File

@ -432,7 +432,7 @@
(types/clj->json accounts-data)))
(defn login [{:keys [key-uid multiaccount-data password]}]
(status/login key-uid multiaccount-data password))
(status/login-with-config key-uid multiaccount-data password nil))
(defn send-transaction-with-signature
[{:keys [transaction on-completed]}]

View File

@ -63,7 +63,7 @@
(re-frame/reg-fx
::login
(fn [[key-uid account-data hashed-password]]
(status/login key-uid account-data hashed-password)))
(status/login-with-config key-uid account-data hashed-password nil)))
(re-frame/reg-fx
::export-db

View File

@ -64,6 +64,16 @@
key-uid
#(.login ^js (status) account-data hashed-password)))
(defn login-with-config
"NOTE: beware, the password has to be sha3 hashed"
[key-uid account-data hashed-password config]
(log/debug "[native-module] loginWithConfig")
(clear-web-data)
(let [config (if config (types/clj->json config) "")]
(init-keystore
key-uid
#(.loginWithConfig ^js (status) account-data hashed-password config))))
(defn export-db
"NOTE: beware, the password has to be sha3 hashed"
[key-uid account-data hashed-password callback]