mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-20 20:01:56 +03:00
updated pin code enabled disable setting response.
This commit is contained in:
parent
07b050c819
commit
bb2a68d0aa
@ -43,6 +43,7 @@ import {
|
|||||||
logoutDone,
|
logoutDone,
|
||||||
closePinCodeModal,
|
closePinCodeModal,
|
||||||
setColorTheme,
|
setColorTheme,
|
||||||
|
setEncryptedUnlockPin,
|
||||||
} from '../../../redux/actions/applicationActions';
|
} from '../../../redux/actions/applicationActions';
|
||||||
import { toastNotification } from '../../../redux/actions/uiAction';
|
import { toastNotification } from '../../../redux/actions/uiAction';
|
||||||
import { setPushToken, getNodes } from '../../../providers/ecency/ecency';
|
import { setPushToken, getNodes } from '../../../providers/ecency/ecency';
|
||||||
@ -225,7 +226,7 @@ class SettingsContainer extends Component {
|
|||||||
if (action) {
|
if (action) {
|
||||||
dispatch(
|
dispatch(
|
||||||
openPinCodeModal({
|
openPinCodeModal({
|
||||||
callback: () => this._setDefaultPinCode(action),
|
callback: () => this._enableDefaultUnlockPin(action),
|
||||||
isReset: true,
|
isReset: true,
|
||||||
isOldPinVerified: true,
|
isOldPinVerified: true,
|
||||||
oldPinCode: Config.DEFAULT_PIN,
|
oldPinCode: Config.DEFAULT_PIN,
|
||||||
@ -234,7 +235,7 @@ class SettingsContainer extends Component {
|
|||||||
} else {
|
} else {
|
||||||
dispatch(
|
dispatch(
|
||||||
openPinCodeModal({
|
openPinCodeModal({
|
||||||
callback: () => this._setDefaultPinCode(action),
|
callback: () => this._enableDefaultUnlockPin(action),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -394,7 +395,6 @@ class SettingsContainer extends Component {
|
|||||||
}
|
}
|
||||||
dispatch(logoutDone());
|
dispatch(logoutDone());
|
||||||
dispatch(isPinCodeOpen(false));
|
dispatch(isPinCodeOpen(false));
|
||||||
setPinCodeOpen(false);
|
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.warn('Failed to remove user data', err);
|
console.warn('Failed to remove user data', err);
|
||||||
@ -419,45 +419,21 @@ class SettingsContainer extends Component {
|
|||||||
}, 500);
|
}, 500);
|
||||||
};
|
};
|
||||||
|
|
||||||
_setDefaultPinCode = (action) => {
|
|
||||||
const { dispatch, username, currentAccount, pinCode } = this.props;
|
|
||||||
|
|
||||||
if (!action) {
|
_enableDefaultUnlockPin = (isEnabled) => {
|
||||||
const oldPinCode = decryptKey(pinCode, Config.PIN_KEY, this._onDecryptFail);
|
const { dispatch, encUnlockPin } = this.props;
|
||||||
|
|
||||||
|
dispatch(isPinCodeOpen(isEnabled));
|
||||||
|
|
||||||
|
if (!isEnabled) {
|
||||||
|
const oldPinCode = decryptKey(encUnlockPin, Config.PIN_KEY, this._onDecryptFail);
|
||||||
|
|
||||||
if (oldPinCode === undefined) {
|
if (oldPinCode === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
const encryptedPin = encryptKey(Config.DEFAULT_PIN, Config.PIN_KEY);
|
||||||
dispatch(savePinCode(encryptedPin));
|
dispatch(setEncryptedUnlockPin(encryptedPin));
|
||||||
|
|
||||||
setPinCodeOpen(action);
|
|
||||||
dispatch(isPinCodeOpen(action));
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.warn('pin update failure: ', err);
|
|
||||||
this._onDecryptFail();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
setPinCodeOpen(action);
|
|
||||||
dispatch(isPinCodeOpen(action));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -483,7 +459,7 @@ const mapStateToProps = (state) => ({
|
|||||||
isDarkTheme: state.application.isDarkTheme,
|
isDarkTheme: state.application.isDarkTheme,
|
||||||
colorTheme: state.application.colorTheme,
|
colorTheme: state.application.colorTheme,
|
||||||
isPinCodeOpen: state.application.isPinCodeOpen,
|
isPinCodeOpen: state.application.isPinCodeOpen,
|
||||||
pinCode: state.application.pin,
|
encUnlockPin: state.application.encUnlockPin,
|
||||||
isDefaultFooter: state.application.isDefaultFooter,
|
isDefaultFooter: state.application.isDefaultFooter,
|
||||||
isLoggedIn: state.application.isLoggedIn,
|
isLoggedIn: state.application.isLoggedIn,
|
||||||
isNotificationSettingsOpen: state.application.isNotificationOpen,
|
isNotificationSettingsOpen: state.application.isNotificationOpen,
|
Loading…
Reference in New Issue
Block a user