mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-20 20:01:56 +03:00
added support for resetting unlock pin
This commit is contained in:
parent
bb2a68d0aa
commit
166016cbdf
@ -120,12 +120,15 @@ class PinCodeContainer extends Component {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_resetPinCode = (pin) =>
|
_resetPinCode = (pin) =>
|
||||||
new Promise((resolve, reject) => {
|
new Promise((resolve, reject) => {
|
||||||
const {
|
const {
|
||||||
currentAccount,
|
currentAccount,
|
||||||
dispatch,
|
dispatch,
|
||||||
pinCodeParams: { navigateTo, navigateParams, accessToken, callback },
|
pinCodeParams: { navigateTo, navigateParams, accessToken, callback },
|
||||||
|
encUnlockPin,
|
||||||
intl,
|
intl,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const { isOldPinVerified, oldPinCode, newPinCode } = this.state;
|
const { isOldPinVerified, oldPinCode, newPinCode } = this.state;
|
||||||
@ -142,16 +145,13 @@ class PinCodeContainer extends Component {
|
|||||||
if (isOldPinVerified) {
|
if (isOldPinVerified) {
|
||||||
//if newPin already exist and pin is a valid pin, compare and set new pin
|
//if newPin already exist and pin is a valid pin, compare and set new pin
|
||||||
if (pin !== undefined && pin === newPinCode) {
|
if (pin !== undefined && pin === newPinCode) {
|
||||||
this._updatePinCodeRealm(pinData).then((status) => {
|
|
||||||
if (!status) {
|
|
||||||
resolve();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this._savePinCode(pin);
|
this._savePinCode(pin);
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(pin, oldPinCode);
|
callback(pin, oldPinCode);
|
||||||
}
|
}
|
||||||
dispatch(closePinCodeModal());
|
dispatch(closePinCodeModal());
|
||||||
|
|
||||||
if (navigateTo) {
|
if (navigateTo) {
|
||||||
navigate({
|
navigate({
|
||||||
routeName: navigateTo,
|
routeName: navigateTo,
|
||||||
@ -159,7 +159,6 @@ class PinCodeContainer extends Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
resolve();
|
resolve();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if newPin code exists and above case failed, that means pins did not match
|
// if newPin code exists and above case failed, that means pins did not match
|
||||||
@ -190,19 +189,12 @@ class PinCodeContainer extends Component {
|
|||||||
|
|
||||||
// if old pin code is not yet verified attempt to verify code
|
// if old pin code is not yet verified attempt to verify code
|
||||||
else {
|
else {
|
||||||
verifyPinCode(pinData)
|
|
||||||
.then(() => {
|
let unlockPin = decryptKey(encUnlockPin, Config.PIN_KEY)
|
||||||
this.setState({ isOldPinVerified: true });
|
|
||||||
this.setState({
|
//check if pins match
|
||||||
informationText: intl.formatMessage({
|
if (unlockPin !== pin) {
|
||||||
id: 'pincode.set_new',
|
const err = new Error("Invalid pin added");
|
||||||
}),
|
|
||||||
newPinCode: null,
|
|
||||||
oldPinCode: pin,
|
|
||||||
});
|
|
||||||
resolve();
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.warn('Failed to verify pin code', err);
|
console.warn('Failed to verify pin code', err);
|
||||||
Alert.alert(
|
Alert.alert(
|
||||||
intl.formatMessage({
|
intl.formatMessage({
|
||||||
@ -213,10 +205,24 @@ class PinCodeContainer extends Component {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
reject(err);
|
reject(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.setState({ isOldPinVerified: true });
|
||||||
|
this.setState({
|
||||||
|
informationText: intl.formatMessage({
|
||||||
|
id: 'pincode.set_new',
|
||||||
|
}),
|
||||||
|
newPinCode: null,
|
||||||
|
oldPinCode: pin,
|
||||||
});
|
});
|
||||||
|
resolve();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_setFirstPinCode = (pin) =>
|
_setFirstPinCode = (pin) =>
|
||||||
new Promise((resolve) => {
|
new Promise((resolve) => {
|
||||||
const {
|
const {
|
||||||
@ -278,7 +284,7 @@ class PinCodeContainer extends Component {
|
|||||||
|
|
||||||
//verifies is the pin entered is right or wrong
|
//verifies is the pin entered is right or wrong
|
||||||
_verifyPinCodeNew = async (pin, { shouldUpdateRealm } = {}) => {
|
_verifyPinCodeNew = async (pin, { shouldUpdateRealm } = {}) => {
|
||||||
try{
|
try {
|
||||||
const {
|
const {
|
||||||
currentAccount,
|
currentAccount,
|
||||||
dispatch,
|
dispatch,
|
||||||
@ -318,7 +324,7 @@ class PinCodeContainer extends Component {
|
|||||||
dispatch(closePinCodeModal());
|
dispatch(closePinCodeModal());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch(err){
|
} catch (err) {
|
||||||
throw err
|
throw err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -414,7 +420,7 @@ class PinCodeContainer extends Component {
|
|||||||
_savePinCode = (pin) => {
|
_savePinCode = (pin) => {
|
||||||
const { dispatch } = this.props;
|
const { dispatch } = this.props;
|
||||||
const encryptedPin = encryptKey(pin, Config.PIN_KEY);
|
const encryptedPin = encryptKey(pin, Config.PIN_KEY);
|
||||||
dispatch(savePinCode(encryptedPin));
|
dispatch(setEncryptedUnlockPin(encryptedPin));
|
||||||
};
|
};
|
||||||
|
|
||||||
_forgotPinCode = async () => {
|
_forgotPinCode = async () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user