Commit 02afb8c4 by Giang Tran

update code

parent 9716afe7
......@@ -20,17 +20,15 @@ import JSEncrypt from 'jsencrypt';
export const encryptRSAString = (val) => {
var encrypt = new JSEncrypt();
encrypt.setPublicKey(MY_RSA_KEY.publicKey);
encrypt.setPublicKey(RSA_KEY.publicKey);
var encrypted = encrypt.encrypt(val);
console.log('Ma hoa', encrypted);
return encrypted;
};
export const decryptRSAString = (val) => {
var decrypt = new JSEncrypt();
decrypt.setPrivateKey(RSA_KEY.privateKey);
decrypt.setPrivateKey(MY_RSA_KEY.privateKey);
var uncrypted = decrypt.decrypt(val);
console.log('giai hoa', uncrypted);
return uncrypted;
};
......
......@@ -20,6 +20,7 @@ import I18n from '../../helper/i18/i18n';
import {showLoading, hideLoading} from '../../actions/loadingAction';
import {connect} from 'react-redux';
import {showAlert, TYPE} from '../../components/DropdownAlert';
import {encryptRSAString} from '../../Config/Functions';
const NewPassword = (props) => {
const [password, setPassword] = useState('');
......@@ -36,8 +37,8 @@ const NewPassword = (props) => {
const res = await forgotPasswordApi({
receiver_name: email,
otp,
password,
password_confirmation: cfPassword,
password: encryptRSAString(password),
password_confirmation: encryptRSAString(cfPassword),
platform: Platform.OS,
});
props.hideLoading();
......
......@@ -16,7 +16,13 @@ import {
useBlurOnFulfill,
useClearByFocusCell,
} from 'react-native-confirmation-code-field';
import {getFontXD, HEIGHTXD, WIDTHXD} from '../../Config/Functions';
import {
getFontXD,
HEIGHTXD,
WIDTHXD,
encryptRSAString,
decryptRSAString,
} from '../../Config/Functions';
import R from '../../assets/R';
import {NEWPASSWORD} from '../../routers/ScreenNames';
import {verifyOTPApi, registorApi, getOTPApi} from '../../apis/Functions/users';
......@@ -52,7 +58,7 @@ const ConfirmOTP = (propsa) => {
const res = await verifyOTPApi({
platform: Platform.OS,
receiver_name: propsa.route.params.email,
otp: value,
otp: encryptRSAString(value),
type: 'CUSTOMER_VERIFY',
});
......@@ -68,18 +74,18 @@ const ConfirmOTP = (propsa) => {
if (sponsor_id) {
res = await registorApi({
email,
password,
password: encryptRSAString(password),
platform: Platform.OS,
password_confirmation,
password_confirmation: encryptRSAString(password_confirmation),
sponsor_id,
phone,
});
} else {
res = await registorApi({
email,
password,
password: encryptRSAString(password),
platform: Platform.OS,
password_confirmation,
password_confirmation: encryptRSAString(password_confirmation),
phone,
});
}
......
......@@ -14,6 +14,7 @@ import {
CONFIRMCREATEOTP,
} from '../../../routers/ScreenNames';
import {useNavigation} from '@react-navigation/native';
import {encryptRSAString} from '../../../Config/Functions';
const ConfirmChangeSmartOTP = (props) => {
const [firstNumber, setFirstNumber] = useState(null);
......@@ -47,9 +48,9 @@ const ConfirmChangeSmartOTP = (props) => {
props.showLoading();
const res = await updateOTPApiSmart({
platform: Platform.OS,
password: props.route.params.pre_otp,
password_confirmation: pinCode,
old_password: props.route.params.old_password,
password: encryptRSAString(props.route.params.pre_otp),
password_confirmation: encryptRSAString(pinCode),
old_password: encryptRSAString(props.route.params.old_password),
});
props.hideLoading();
if (res.data.code == 200) {
......
......@@ -16,7 +16,12 @@ import {
useBlurOnFulfill,
useClearByFocusCell,
} from 'react-native-confirmation-code-field';
import {getFontXD, HEIGHTXD, WIDTHXD} from '../../../Config/Functions';
import {
getFontXD,
HEIGHTXD,
WIDTHXD,
encryptRSAString,
} from '../../../Config/Functions';
import R from '../../../assets/R';
import {NEWPASSWORD, TABNAVIGATOR} from '../../../routers/ScreenNames';
import {
......@@ -75,8 +80,10 @@ const ConfirmOTP = (propsa) => {
propsa.showLoading();
const res = await verifyStoreOTPApiSmart({
platform: Platform.OS,
password: propsa.route.params.password,
password_confirmation: propsa.route.params.password_confirmation,
password: encryptRSAString(propsa.route.params.password),
password_confirmation: encryptRSAString(
propsa.route.params.password_confirmation,
),
otp: value,
type: 'CREATE_OTP_PASSWORD',
});
......
......@@ -23,6 +23,7 @@ import {
verifyStoreOTPApiSmart,
getOTPApiSmartOTP,
} from '../../apis/Functions/users';
import {encryptRSAString} from '../../Config/Functions';
const CELL_COUNT = 4;
......@@ -63,8 +64,10 @@ const ConfirmOTPSmart = (propsa) => {
propsa.showLoading();
const res = await verifyStoreOTPApiSmart({
platform: Platform.OS,
password: propsa.route.params.password,
password_confirmation: propsa.route.params.password_confirmation,
password: encryptRSAString(propsa.route.params.password),
password_confirmation: encryptRSAString(
propsa.route.params.password_confirmation,
),
otp: value,
type: 'CREATE_OTP_PASSWORD',
});
......
......@@ -8,6 +8,7 @@ import {hideLoading, showLoading} from '../../actions/loadingAction';
import {OTP_TYPE} from '../../Config/constants';
import {useNavigation} from '@react-navigation/native';
import {RESET_SMART_OTP, CHANGESMARTOTP} from '../../routers/ScreenNames';
import {decryptRSAString, encryptRSAString} from '../../Config/Functions';
const EnterPasswordSmartOTP = (props) => {
const navigation = useNavigation();
......@@ -38,12 +39,12 @@ const EnterPasswordSmartOTP = (props) => {
if (props.route.params.type == 'CHANGE_SMART_OTP') {
const res = await verifyOTPApiSmart({
platform: Platform.OS,
otp_password: pinCode,
otp_password: encryptRSAString(pinCode),
type: 'VERIFY_OTP_PASSWORD',
});
if (res.data.code == 200) {
navigation.navigate(CHANGESMARTOTP, {
old_password: pinCode,
old_password: encryptRSAString(pinCode),
TYPE: 'CHANGE_SMART_OTP',
});
clearPIN();
......@@ -55,7 +56,7 @@ const EnterPasswordSmartOTP = (props) => {
const res = await getOTPApiSmartOTP({
platform: Platform.OS,
otp_by: props.user.email,
otp_password: pinCode,
otp_password: encryptRSAString(pinCode),
type:
props.route.params.type == 'DEPOSIT'
? OTP_TYPE.CUSTOMER_REQUEST_DEPOSIT
......@@ -63,7 +64,10 @@ const EnterPasswordSmartOTP = (props) => {
});
if (res.data.code == 200) {
props.route.params.onGoToSmartOTP(pinCode, res.data.data.otp);
props.route.params.onGoToSmartOTP(
pinCode,
decryptRSAString(res.data.data.otp),
);
} else {
showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
clearPIN();
......
......@@ -11,7 +11,7 @@ import {connect} from 'react-redux';
import {hideLoading, showLoading} from '../../actions/loadingAction';
import {OTP_TYPE} from '../../Config/constants';
import {useNavigation} from '@react-navigation/native';
import {encryptRSAString, decryptRSAString} from '../../Config/Functions';
const SmartOTP = (props) => {
const [value, setValue] = useState(props.route.params.otp);
......@@ -31,8 +31,11 @@ const SmartOTP = (props) => {
let res1 = await verifyOTPApi({
platform: Platform.OS,
receiver_name: props.user.email,
otp: value,
type: props.route.params.type == 'DEPOSIT' ? OTP_TYPE.CUSTOMER_REQUEST_DEPOSIT : OTP_TYPE.REQUEST_WITHDRAW,
otp: encryptRSAString(value),
type:
props.route.params.type == 'DEPOSIT'
? OTP_TYPE.CUSTOMER_REQUEST_DEPOSIT
: OTP_TYPE.REQUEST_WITHDRAW,
});
if (res1.data.code == 200) {
......@@ -80,11 +83,14 @@ const SmartOTP = (props) => {
const res = await getOTPApiSmartOTP({
platform: Platform.OS,
otp_by: props.user.email,
otp_password: props.route.params.pinCode,
type: props.route.params.type == 'DEPOSIT' ? OTP_TYPE.CUSTOMER_REQUEST_DEPOSIT : OTP_TYPE.REQUEST_WITHDRAW,
otp_password: encryptRSAString(props.route.params.pinCode),
type:
props.route.params.type == 'DEPOSIT'
? OTP_TYPE.CUSTOMER_REQUEST_DEPOSIT
: OTP_TYPE.REQUEST_WITHDRAW,
});
if (res.data.code == 200) {
setValue(res.data.data.otp);
setValue(decryptRSAString(res.data.data.otp));
setReset(!isReset);
} else {
showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
......@@ -96,14 +102,17 @@ const SmartOTP = (props) => {
setProgress(count > 0 ? count / 300 : 0);
};
return <SmartOTPView
return (
<SmartOTPView
value={value}
progress={progress}
confirm={confirm}
isReset={isReset}
getNewOTP={getNewOTP}
updateProgress={updateProgress}
setValue={setValue}/>;
setValue={setValue}
/>
);
};
const mapStateToProps = (state) => {
return {
......
......@@ -16,7 +16,12 @@ import {
useBlurOnFulfill,
useClearByFocusCell,
} from 'react-native-confirmation-code-field';
import {getFontXD, HEIGHTXD, WIDTHXD} from '../../Config/Functions';
import {
getFontXD,
HEIGHTXD,
WIDTHXD,
encryptRSAString,
} from '../../Config/Functions';
import R from '../../assets/R';
import {TABNAVIGATOR} from '../../routers/ScreenNames';
import {verifyOTPApi} from '../../apis/Functions/users';
......@@ -68,8 +73,10 @@ const ConfirmOTPSmart = (propsa) => {
propsa.showLoading();
const res = await verifyStoreOTPApiSmart({
platform: Platform.OS,
password: propsa.route.params.password,
password_confirmation: propsa.route.params.password_confirmation,
password: encryptRSAString(propsa.route.params.password),
password_confirmation: encryptRSAString(
propsa.route.params.password_confirmation,
),
otp: value,
type: 'FORGOT_PASSWORD',
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment