Close pin code feature adde

This commit is contained in:
Mustafa Buyukcelebi 2019-07-18 19:58:44 +03:00
parent bd1009d23f
commit 375b2f8ec9
4 changed files with 30 additions and 11 deletions

View File

@ -3,6 +3,7 @@ BACKEND_URL=
NEW_IMAGE_API=
OLD_IMAGE_API=
PIN_KEY=
DEFAULT_PIN=
SEARCH_API_TOKEN=
SEARCH_API_URL=
SERVER_LIST_API=

View File

@ -110,7 +110,7 @@ class LoginContainer extends PureComponent {
_getAccountsWithUsername = async username => {
const { intl, isConnected } = this.props;
if (isConnected) return null;
if (!isConnected) return null;
try {
const validUsers = await lookupAccounts(username);

View File

@ -4,6 +4,7 @@ import { connect } from 'react-redux';
import { injectIntl } from 'react-intl';
import Config from 'react-native-config';
import { NavigationActions } from 'react-navigation';
import get from 'lodash/get';
// Actions & Services
import {
@ -41,8 +42,8 @@ class PinCodeContainer extends Component {
isExistUser: null,
informationText: '',
pinCode: null,
isOldPinVerified: false,
oldPinCode: null,
isOldPinVerified: get(props.pinCodeParams, 'isOldPinVerified', false),
oldPinCode: get(props.pinCodeParams, 'oldPinCode', null),
};
}

View File

@ -45,7 +45,7 @@ import { VALUE as LANGUAGE_VALUE } from '../../../constants/options/language';
// Utilities
import { sendEmail } from '../../../utils/sendEmail';
import { encryptKey } from '../../../utils/crypto';
import { encryptKey, decryptKey } from '../../../utils/crypto';
// Component
import SettingsScreen from '../screen/settingsScreen';
@ -174,11 +174,22 @@ class SettingsContainer extends Component {
break;
case 'pincode':
dispatch(
openPinCodeModal({
callback: (pinCode, oldPincode) => this._setDefaultPinCode(action, oldPincode),
}),
);
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;
@ -300,10 +311,11 @@ class SettingsContainer extends Component {
}
};
_setDefaultPinCode = (action, oldPinCode) => {
const { dispatch, username, currentAccount } = this.props;
_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,
@ -321,6 +333,9 @@ class SettingsContainer extends Component {
setPinCodeOpen(action);
dispatch(isPinCodeOpen(action));
});
} else {
setPinCodeOpen(action);
dispatch(isPinCodeOpen(action));
}
};
@ -342,6 +357,7 @@ class SettingsContainer extends Component {
const mapStateToProps = state => ({
isDarkTheme: state.application.isDarkTheme,
isPinCodeOpen: state.application.isPinCodeOpen,
pinCode: state.application.pin,
isDefaultFooter: state.application.isDefaultFooter,
isLoggedIn: state.application.isLoggedIn,
isNotificationSettingsOpen: state.application.isNotificationOpen,
@ -356,6 +372,7 @@ const mapStateToProps = state => ({
selectedApi: state.application.api,
selectedCurrency: state.application.currency,
selectedLanguage: state.application.language,
username: state.account.currentAccount && state.account.currentAccount.name,
currentAccount: state.account.currentAccount,
});