Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (realmData.length > 0) {
const realmObject = realmData.filter(data => data.username === currentUsername);
if (realmObject.length === 0) {
realmObject[0] = realmData[realmData.length - 1];
// TODO:
await switchAccount(realmObject[0].username);
}
const isExistUser = await getExistUser();
realmObject[0].name = currentUsername;
// If in dev mode pin code does not show
if ((!isExistUser || !pinCode) && _isPinCodeOpen) {
dispatch(openPinCodeModal());
} else if (!_isPinCodeOpen) {
const encryptedPin = encryptKey(Config.DEFAULT_PIN, Config.PIN_KEY);
dispatch(savePinCode(encryptedPin));
}
dispatch(activeApplication());
dispatch(isLoginDone());
dispatch(login(true));
return realmObject[0];
}
dispatch(updateCurrentAccount({}));
dispatch(activeApplication());
dispatch(isLoginDone());
return null;
};
setTheme(action);
break;
case 'default_footer':
dispatch(isDefaultFooter(action));
// setDefaultFooter(action);
break;
case 'pincode':
if (action) {
dispatch(
openPinCodeModal({
callback: () => this._setDefaultPinCode(action),
isReset: true,
isOldPinVerified: true,
oldPinCode: Config.DEFAULT_PIN,
}),
);
} else {
dispatch(
openPinCodeModal({
callback: () => this._setDefaultPinCode(action),
}),
);
}
break;
default:
break;
}
};
.then(result => {
if (result) {
dispatch(updateCurrentAccount({ ...result }));
dispatch(addOtherAccount({ username: result.name }));
dispatch(loginAction(true));
userActivity(result.name, 20);
this._setPushToken(result.name);
if (isPinCodeOpen) {
dispatch(openPinCodeModal({ navigateTo: ROUTES.DRAWER.MAIN }));
} else {
const encryptedPin = encryptKey(Config.DEFAULT_PIN, Config.PIN_KEY);
dispatch(setPinCode(encryptedPin));
navigation.navigate({
routeName: ROUTES.DRAWER.MAIN,
});
}
}
})
.catch(err => {
updatePinCode(pinData).then(response => {
const _currentAccount = currentAccount;
_currentAccount.local = response;
dispatch(updateCurrentAccount({ ..._currentAccount }));
const encryptedPin = encryptKey(Config.DEFAULT_PIN, Config.PIN_KEY);
dispatch(savePinCode(encryptedPin));
setPinCodeOpen(action);
dispatch(isPinCodeOpen(action));
});
} else {
_setDefaultPinCode = action => {
const { dispatch, username, currentAccount, pinCode } = this.props;
if (!action) {
const oldPinCode = decryptKey(pinCode, Config.PIN_KEY);
const pinData = {
pinCode: Config.DEFAULT_PIN,
username,
oldPinCode,
};
updatePinCode(pinData).then(response => {
const _currentAccount = currentAccount;
_currentAccount.local = response;
dispatch(updateCurrentAccount({ ..._currentAccount }));
const encryptedPin = encryptKey(Config.DEFAULT_PIN, Config.PIN_KEY);
dispatch(savePinCode(encryptedPin));
setPinCodeOpen(action);
dispatch(isPinCodeOpen(action));
});
} else {