Sécurisation du wallet

This commit is contained in:
Brice Zele 2022-04-21 12:14:21 +01:00
parent 441726e561
commit f7679e4f14
15 changed files with 1463 additions and 1201 deletions

View File

@ -129,6 +129,7 @@ android {
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
}
lintOptions { checkReleaseBuilds false }
ndkVersion rootProject.ext.ndkVersion
compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions {

File diff suppressed because one or more lines are too long

View File

@ -4,6 +4,7 @@ buildscript {
minSdkVersion = 16
compileSdkVersion = 29
targetSdkVersion = 29
ndkVersion = "21.4.7075529"
}
repositories {
google()

View File

@ -15,6 +15,10 @@ import {
LINK_CARD_PENDING,
LINK_CARD_RESET,
LINK_CARD_SUCCESS,
PASSWORD_VALIDATION_ERROR,
PASSWORD_VALIDATION_PENDING,
PASSWORD_VALIDATION_RESET,
PASSWORD_VALIDATION_SUCCESS,
PAY_BILL_ERROR,
PAY_BILL_PENDING,
PAY_BILL_RESET,
@ -319,3 +323,21 @@ export const fetchGetQRCodeDetailError = (error) => ({
type: GET_QR_CODE_DETAIL_ERROR,
result: error
});
/**
* ---------------------------------------------------
*/
export const fetchPasswordValidationPending = () => ({
type: PASSWORD_VALIDATION_PENDING
});
export const fetchPasswordValidationReset = () => ({
type: PASSWORD_VALIDATION_RESET
});
export const fetchPasswordValidationSuccess = (res) => ({
type: PASSWORD_VALIDATION_SUCCESS,
result: res,
});
export const fetchPasswordValidationError = (error) => ({
type: PASSWORD_VALIDATION_ERROR,
result: error
});

View File

@ -0,0 +1,44 @@
/**
* @Project iLinkWorld
* @File PasswordValidationReducer.js
* @Path redux/reducers
* @Author BRICE ZELE
* @Date 21/04/2022
*/
import * as WalletType from "../types/WalletType";
const initialState = {
loading: false,
result: null,
error: null
};
export default (state = initialState, action) => {
switch (action.type) {
case WalletType.PASSWORD_VALIDATION_PENDING:
return {
...state,
loading: true
}
case WalletType.PASSWORD_VALIDATION_SUCCESS:
return {
...state,
loading: false,
result: action.result.data,
error: null
}
case WalletType.PASSWORD_VALIDATION_ERROR:
return {
...state,
loading: false,
result: null,
error: action.result.data.error
}
case WalletType.PASSWORD_VALIDATION_RESET:
return initialState;
default: {
return state;
}
}
};

View File

@ -80,6 +80,7 @@ import {
} from "../insurance/insurance.reducer";
import SearchUserReducer from "./SearchUserReducer";
import GetQRCodeDetailReducer from "./GetQRCodeDetailReducer";
import PasswordValidationReducer from "./PasswordValidationReducer";
const persistConfig = {
key: 'root',
@ -193,6 +194,7 @@ const rootReducer = persistCombineReducers(persistConfig, {
checkInsuranceCoverageAmountReducer: checkInsuranceCoverageAmountReducer,
searchUserReducer: SearchUserReducer,
getQRCodeDetailReducer: GetQRCodeDetailReducer,
passwordValidationReducer: PasswordValidationReducer,
getExclusionReducer: getExclusionReducer
});

View File

@ -68,3 +68,8 @@ export const GET_QR_CODE_DETAIL_PENDING = 'GET_QR_CODE_DETAIL_PENDING';
export const GET_QR_CODE_DETAIL_SUCCESS = 'GET_QR_CODE_DETAIL_SUCCESS';
export const GET_QR_CODE_DETAIL_ERROR = 'GET_QR_CODE_DETAIL_ERROR';
export const GET_QR_CODE_DETAIL_RESET = 'GET_QR_CODE_DETAIL_RESET';
export const PASSWORD_VALIDATION_PENDING = 'PASSWORD_VALIDATION_PENDING';
export const PASSWORD_VALIDATION_SUCCESS = 'PASSWORD_VALIDATION_SUCCESS';
export const PASSWORD_VALIDATION_ERROR = 'PASSWORD_VALIDATION_ERROR';
export const PASSWORD_VALIDATION_RESET = 'PASSWORD_VALIDATION_RESET';

View File

@ -52,7 +52,12 @@ import {
} from '../../utils/UtilsFunction';
import {depositActionReset} from '../../webservice/DepositApi';
import {baseUrl} from '../../webservice/IlinkConstants';
import {getWalletDetailActivated, resetWalletListDetailReducer} from '../../webservice/WalletApi';
import {
getWalletDetailActivated,
passwordValidationAction,
passwordValidationReset,
resetWalletListDetailReducer
} from '../../webservice/WalletApi';
import {
getHyperSuperTransactionHistoryAction,
getHyperSuperTransactionHistoryReset,
@ -73,6 +78,11 @@ import {
fetchGetUserByNameOrNumberReset
} from "../../redux/insurance/insurance.actions";
import {facturerSoinReset} from "../../webservice/NanoCreditApi";
import FontAwesomeIcon from "react-native-vector-icons/FontAwesome";
import * as Animatable from 'react-native-animatable';
import {Fumi} from 'react-native-textinput-effects';
import Button from "../../components/Button";
let moment = require('moment-timezone');
const thousands = require('thousands');
@ -101,7 +111,9 @@ class WalletDetail extends Component {
displayModalHistory: false,
displaySuperHyperModalHistory: false,
historyItemDetail: null,
user: null
user: null,
password: '',
isLogged: false
};
this.renderContent = null;
@ -129,6 +141,7 @@ class WalletDetail extends Component {
this.props.fetchGetConsultationReset();
this.props.fetchGetNetworkActsReset();
this.props.facturerSoinReset();
this.props.passwordValidationReset();
this.currentLocale = I18n.locale.includes("fr") ? "fr" : "en-gb";
moment.locale(this.currentLocale);
@ -346,17 +359,44 @@ class WalletDetail extends Component {
}
}
/* componentWillReceiveProps(nextProps) {
componentWillReceiveProps(nextProps) {
if (nextProps.resultPasswordValidation !== null) {
if (nextProps.resultPasswordValidation.status === 200) {
this.setState({
isLogged: true
});
this.props.passwordValidationReset();
}
}
if (nextProps.errorPasswordValidation !== null) {
console.log(nextProps.errorPasswordValidation);
Alert.alert(
I18n.t("ERROR_LABEL"),
'' + nextProps.errorPasswordValidation,
[
{
text: I18n.t("OK"), onPress: () => {
this.props.passwordValidationReset();
}
}
],
{cancelable: false}
);
this.setState({
isLogged: false
});
}
if (nextProps.loading || nextProps.loadingTransferCommission)
/* if (nextProps.loading || nextProps.loadingTransferCommission)
this.setState({
loading: true
})
else
this.setState({
loading: false
})
} */
})*/
}
getWalletIcon = (wallet) => {
return `${baseUrl}/datas/img/network/${slugify(wallet.network, {lower: true})}-logo.png`;
@ -1495,6 +1535,7 @@ class WalletDetail extends Component {
)
else {
return (
<>
<View key={index} style={styles.transactionContainer}>
{this.renderItem(item[0], false, 0)}
<>
@ -1507,11 +1548,11 @@ class WalletDetail extends Component {
source: require("./../../datas/json/identification.json"),
loop: true
}
})
});
}}
activeOpacity={0.9}>
<Icon name='pencil-plus'
<Icon name='history'
color={Color.primaryColor}
size={30}
style={styles.imageBanner}/>
@ -1537,6 +1578,43 @@ class WalletDetail extends Component {
</View>
</>
</View>
<View key={index} style={styles.transactionContainer}>
<>
<View style={[styles.containerTouch]}>
<TouchableOpacity style={styles.contain}
onPress={() => {
this.props.navigation.push(route.historiqueNanoSanteAgentScreen);
}}
activeOpacity={0.9}>
<Icon name='pencil-plus'
color={Color.primaryColor}
size={30}
style={styles.imageBanner}/>
<View style={[styles.content]}>
<View style={styles.contentTitle}>
<Text
style={[Typography.headline, Typography.semibold]}>
{I18n.t('HISTORY')}
</Text>
</View>
<View style={{flex: 1}}>
<Text
style={[Typography.overline, Color.grayColor], {paddingVertical: 5}}
numberOfLines={5}>
</Text>
</View>
</View>
</TouchableOpacity>
</View>
<View/>
</>
</View>
</>
)
}
})
@ -2058,6 +2136,39 @@ class WalletDetail extends Component {
</View>
:
this.props.result.response.password_validation === "MIN" && !this.state.isLogged ?
<ScrollView style={{flex: 1, padding: 20}}>
<Animatable.View ref={(comp) => {
this.codeAgentAnim = comp
}}>
<Fumi iconClass={FontAwesomeIcon}
label={I18n.t('PASSWORD')}
iconColor={'#f95a25'}
iconSize={20}
secureTextEntry
iconName="lock"
value={this.state.password}
onChangeText={(password) => {
this.setState({password});
}}
style={styles.input}
>
</Fumi>
</Animatable.View>
<Button
loading={this.props.loadingPasswordValidation}
onPress={() => {
this.props.passwordValidationAction({
password: this.state.password,
user_id: this.props.navigation.state.params.agentId,
network_agent_id: this.props.result.response.network_agent_id
});
}}>
{I18n.t('SUBMIT_LABEL')}
</Button>
</ScrollView>
:
this.renderDetailWallet(this.props.result.response)
:
null
@ -2088,6 +2199,10 @@ const mapStateToProps = state => ({
loadingHistoryHyperSuper: state.getHyperSuperHistoryReducer.loading,
resultHistoryHyperSuper: state.getHyperSuperHistoryReducer.result,
errorHistoryHyperSuper: state.getHyperSuperHistoryReducer.error,
loadingPasswordValidation: state.passwordValidationReducer.loading,
resultPasswordValidation: state.passwordValidationReducer.result,
errorPasswordValidation: state.passwordValidationReducer.error,
});
const mapDispatchToProps = dispatch => bindActionCreators({
@ -2100,6 +2215,9 @@ const mapDispatchToProps = dispatch => bindActionCreators({
depositActionReset,
getHyperSuperTransactionHistoryAction,
getHyperSuperTransactionHistoryReset,
passwordValidationAction,
passwordValidationReset,
fetchGetSubscriptionListReset,
fetchGetDrugAppareilReset,
@ -2121,6 +2239,13 @@ const styles = StyleSheet.create({
indicator: {
height: 2
},
input: {
height: 60,
width: '100%',
borderRadius: 5,
borderWidth: 0.5,
marginBottom: 20,
},
tab: {
width: Utils.getWidthDevice() / 2
},
@ -2191,6 +2316,14 @@ const styles = StyleSheet.create({
paddingVertical: 10,
marginTop: 5
},
btnvalide: {
marginTop: 20,
marginLeft: 20,
marginRight: 20,
borderColor: 'transparent',
backgroundColor: Color.accentLightColor,
height: 52
},
blockView: {
paddingVertical: 10,
borderBottomWidth: 0.5,

View File

@ -521,8 +521,7 @@ const ExecuterPrescriptionScreen = ({
const ExecuterPrescriptionSchema = Yup.object().shape({
numero_assure: Yup.string()
.required(I18n.t('THIS_FIELD_IS_REQUIRED')),
password: Yup.string()
.required(I18n.t('THIS_FIELD_IS_REQUIRED')),
password: Yup.string(),
practitioner_lastname: Yup.string()
.required(I18n.t('THIS_FIELD_IS_REQUIRED')),
practitioner_firstname: Yup.string()
@ -1632,6 +1631,9 @@ const ExecuterPrescriptionScreen = ({
/>
</Animatable.View>
{
wallet.password_validation === "MAX" &&
<TextInput
style={{marginTop: 10}}
placeholder={I18n.t('PASSWORD')}
@ -1643,6 +1645,7 @@ const ExecuterPrescriptionScreen = ({
error={errors.password}
secureTextEntry
/>
}
<View
style={{

View File

@ -531,8 +531,7 @@ const ModifierExecutionPrescriptionScreen = ({
const ExecuterPrescriptionSchema = Yup.object().shape({
numero_assure: Yup.string()
.required(I18n.t('THIS_FIELD_IS_REQUIRED')),
password: Yup.string()
.required(I18n.t('THIS_FIELD_IS_REQUIRED')),
password: Yup.string(),
practitioner_lastname: Yup.string()
.required(I18n.t('THIS_FIELD_IS_REQUIRED')),
practitioner_firstname: Yup.string()
@ -1617,6 +1616,8 @@ const ModifierExecutionPrescriptionScreen = ({
/>
</Animatable.View>
{
wallet.password_validation === "MAX" &&
<TextInput
style={{marginTop: 10}}
placeholder={I18n.t('PASSWORD')}
@ -1628,6 +1629,7 @@ const ModifierExecutionPrescriptionScreen = ({
error={errors.password}
secureTextEntry
/>
}
<View
style={{

View File

@ -598,8 +598,7 @@ const ModifierFeuilleSoinScreen = ({
const ModifierFeuilleSoinSchema = Yup.object().shape({
numero_assure: Yup.string()
.required(I18n.t('THIS_FIELD_IS_REQUIRED')),
password: Yup.string()
.required(I18n.t('THIS_FIELD_IS_REQUIRED')),
password: Yup.string(),
practitioner_lastname: Yup.string()
.required(I18n.t('THIS_FIELD_IS_REQUIRED')),
practitioner_firstname: Yup.string()
@ -3004,6 +3003,8 @@ const ModifierFeuilleSoinScreen = ({
)
}
{
wallet.password_validation === "MAX" &&
<TextInput
style={{marginTop: 10}}
placeholder={I18n.t('PASSWORD')}
@ -3015,6 +3016,7 @@ const ModifierFeuilleSoinScreen = ({
error={errors.password}
secureTextEntry
/>
}
<View
style={{

View File

@ -679,8 +679,7 @@ const SaisirFeuilleSoinScreen = ({
const SaisirFeuilleSoinSchema = Yup.object().shape({
numero_assure: Yup.string()
.required(I18n.t('THIS_FIELD_IS_REQUIRED')),
password: Yup.string()
.required(I18n.t('THIS_FIELD_IS_REQUIRED')),
password: Yup.string(),
practitioner_lastname: Yup.string()
.required(I18n.t('THIS_FIELD_IS_REQUIRED')),
practitioner_firstname: Yup.string()
@ -2057,6 +2056,8 @@ const SaisirFeuilleSoinScreen = ({
)
}
{
wallet.password_validation === "MAX" &&
<TextInput
style={{marginTop: 10}}
placeholder={I18n.t('PASSWORD')}
@ -2068,6 +2069,7 @@ const SaisirFeuilleSoinScreen = ({
error={errors.password}
secureTextEntry
/>
}
<View
style={{

View File

@ -58,7 +58,6 @@ import {useFormik} from "formik";
import * as Animatable from "react-native-animatable";
import {responsiveWidth} from "react-native-responsive-dimensions";
import {Dropdown} from "react-native-material-dropdown";
import PasswordInput from "../../../components/PasswordInput";
import FontAwesome from "react-native-vector-icons/FontAwesome";
import Button from "../../../components/Button";
import * as Yup from "yup";
@ -137,7 +136,6 @@ const DemandeAutorisationSoinScreen = ({
const RegisterSchema = Yup.object().shape({
password: Yup.string()
.required(I18n.t('THIS_FIELD_IS_REQUIRED'))
});
useEffect(() => {
@ -745,7 +743,9 @@ const DemandeAutorisationSoinScreen = ({
/>
</Animatable.View>
<PasswordInput
{
wallet.password_validation === "MAX" &&
<TextInput
style={{marginTop: 10, width: responsiveWidth(90)}}
onChangeText={handleChange('password')}
placeholder={I18n.t('PASSWORD')}
@ -757,6 +757,7 @@ const DemandeAutorisationSoinScreen = ({
touched={touched.password}
error={errors.password}
/>
}
<Button
style={{marginTop: 20}}

View File

@ -102,6 +102,7 @@ export const getNetworkActsUrl = testBaseUrl + '/nanoSanteService/acts';
export const createConsultationUrl = testBaseUrl + '/nanoSanteService/health-care-sheets/consultation';
export const executionPrescriptionUrl = testBaseUrl + '/nanoSanteService/health-care-sheets/execution';
export const consultationUrl = testBaseUrl + '/nanoSanteService/health-care-sheets';
export const passwordValidationUrl = testBaseUrl + '/nanoSanteService/password-validation';
export const getAmountConsultationUrl = testBaseUrl + '/nanoSanteService/health-care-sheets/performances-amount';
export const getInsurancePrimeAmountUrl = testBaseUrl + '/nanoSanteService/insurances/subscriptions/bonus-amount';
export const autorisationCareRequestUrl = testBaseUrl + '/nanoSanteService/authorizations-care-requests';

View File

@ -5,6 +5,7 @@ import {
getQRCodeDetail,
linkBankAccountUrl,
linkCardUrl,
passwordValidationUrl,
payBillUrl,
searchUserHomeUrl,
searchUserUrl,
@ -29,6 +30,10 @@ import {
fetchLinkCardPending,
fetchLinkCardReset,
fetchLinkCardSuccess,
fetchPasswordValidationError,
fetchPasswordValidationPending,
fetchPasswordValidationReset,
fetchPasswordValidationSuccess,
fetchPayBillError,
fetchPayBillPending,
fetchPayBillReset,
@ -436,3 +441,40 @@ export const getQRCodeDetailReset = () => {
dispatch(fetchGetQRCodeDetailReset());
}
};
export const passwordValidationAction = (data) => {
const auth = store.getState().authKeyReducer;
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
return dispatch => {
dispatch(fetchPasswordValidationPending());
axios({
url: `${passwordValidationUrl}`,
method: 'POST',
headers: {
'Authorization': authKey,
'X-Localization': I18n.currentLocale()
},
data
})
.then(response => {
console.log(response);
dispatch(fetchPasswordValidationSuccess(response));
})
.catch(error => {
if (error.response)
dispatch(fetchPasswordValidationError(error.response));
else if (error.request)
dispatch(fetchPasswordValidationError(error.request));
else
dispatch(fetchPasswordValidationError(error.message));
});
}
}
export const passwordValidationReset = () => {
return dispatch => {
dispatch(fetchPasswordValidationReset());
}
};