Fixed #883. Fixed pin code crash issue

This commit is contained in:
Mustafa Buyukcelebi 2019-11-20 17:52:55 +03:00
parent e96ffb2ccb
commit 643c4ce08e
2 changed files with 42 additions and 31 deletions

View File

@ -245,39 +245,50 @@ class PinCodeContainer extends Component {
const { intl, currentAccount, applicationPinCode } = this.props; const { intl, currentAccount, applicationPinCode } = this.props;
const { isExistUser, pinCode } = this.state; const { isExistUser, pinCode } = this.state;
const realmData = await getUserDataWithUsername(currentAccount.name); try {
const userData = realmData[0]; const realmData = await getUserDataWithUsername(currentAccount.name);
const userData = realmData[0];
// For exist users // For exist users
if (isReset) { if (isReset) {
await this._resetPinCode(pin); await this._resetPinCode(pin);
return true; return true;
} }
if (isExistUser) { if (isExistUser) {
if (!userData.accessToken && !userData.masterKey && applicationPinCode) { if (!userData.accessToken && !userData.masterKey && applicationPinCode) {
const verifiedPin = decryptKey(applicationPinCode, Config.PIN_KEY); const verifiedPin = decryptKey(applicationPinCode, Config.PIN_KEY);
if (verifiedPin === pin) { if (verifiedPin === pin) {
await this._setFirstPinCode(pin); await this._setFirstPinCode(pin);
} else { } else {
Alert.alert( Alert.alert(
intl.formatMessage({ intl.formatMessage({
id: 'alert.warning', id: 'alert.warning',
}), }),
intl.formatMessage({ intl.formatMessage({
id: 'alert.invalid_pincode', id: 'alert.invalid_pincode',
}), }),
); );
} }
} else { } else {
await this._verifyPinCode(pin); await this._verifyPinCode(pin);
}
return true;
} }
return true;
}
// For new users // For new users
if (pinCode === pin) { if (pinCode === pin) {
await this._setFirstPinCode(pin); await this._setFirstPinCode(pin);
return true; return true;
}
} catch (error) {
Alert.alert(
intl.formatMessage({
id: 'alert.warning',
}),
intl.formatMessage({
id: error.message,
}),
);
} }
if (!pinCode) { if (!pinCode) {

View File

@ -158,7 +158,7 @@ export const groomingWalletData = async (user, globalProps) => {
walletData.showPowerDown = user.next_vesting_withdrawal !== '1969-12-31T23:59:59'; walletData.showPowerDown = user.next_vesting_withdrawal !== '1969-12-31T23:59:59';
const timeDiff = Math.abs(parseDate(user.next_vesting_withdrawal) - new Date()); const timeDiff = Math.abs(parseDate(user.next_vesting_withdrawal) - new Date());
walletData.nextVestingWithdrawal = Math.ceil(timeDiff / (1000 * 3600 * 24)); walletData.nextVestingWithdrawal = Math.floor(timeDiff / (1000 * 3600 * 24));
const { transfer_history: transferHistory } = get(accounts, user.name, []); const { transfer_history: transferHistory } = get(accounts, user.name, []);
walletData.transactions = transferHistory walletData.transactions = transferHistory