Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
InvestCustomer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Giang Tran
InvestCustomer
Commits
02afb8c4
Commit
02afb8c4
authored
Jun 11, 2021
by
Giang Tran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update code
parent
9716afe7
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
149 additions
and
113 deletions
+149
-113
Functions.js
src/Config/Functions.js
+2
-4
NewPassWord.js
src/Screens/Authen/NewPassWord.js
+3
-2
RegisterOTP.js
src/Screens/Authen/RegisterOTP.js
+12
-6
ConfirmChangeSmartOTP.js
src/Screens/SmartOTP/ChangeSmartOTP/ConfirmChangeSmartOTP.js
+4
-3
ConfirmCreate.js
src/Screens/SmartOTP/ConfirmCreate/ConfirmCreate.js
+10
-3
ConfirmOTPSmart.js
src/Screens/SmartOTP/ConfirmOTPSmart.js
+5
-2
EnterPasswordSmartOTP.js
src/Screens/SmartOTP/EnterPasswordSmartOTP.js
+8
-4
SmartOTP.js
src/Screens/SmartOTP/SmartOTP.js
+95
-86
ConfirmOTPSmart.js
src/apis/Functions/ConfirmOTPSmart.js
+10
-3
No files found.
src/Config/Functions.js
View file @
02afb8c4
...
...
@@ -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
;
};
...
...
src/Screens/Authen/NewPassWord.js
View file @
02afb8c4
...
...
@@ -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
();
...
...
src/Screens/Authen/RegisterOTP.js
View file @
02afb8c4
...
...
@@ -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
,
});
}
...
...
src/Screens/SmartOTP/ChangeSmartOTP/ConfirmChangeSmartOTP.js
View file @
02afb8c4
...
...
@@ -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
)
{
...
...
src/Screens/SmartOTP/ConfirmCreate/ConfirmCreate.js
View file @
02afb8c4
...
...
@@ -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'
,
});
...
...
src/Screens/SmartOTP/ConfirmOTPSmart.js
View file @
02afb8c4
...
...
@@ -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'
,
});
...
...
src/Screens/SmartOTP/EnterPasswordSmartOTP.js
View file @
02afb8c4
...
...
@@ -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
();
...
...
src/Screens/SmartOTP/SmartOTP.js
View file @
02afb8c4
...
...
@@ -11,104 +11,113 @@ 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
);
const
[
progress
,
setProgress
]
=
useState
(
1
);
const
[
isReset
,
setReset
]
=
useState
(
false
);
const
navigate
=
useNavigation
();
useEffect
(()
=>
{
setValue
(
props
.
route
.
params
.
otp
);
},
[
props
.
route
.
params
.
otp
]);
const
confirm
=
async
()
=>
{
if
(
!
value
)
{
showAlert
(
TYPE
.
WARN
,
I18n
.
t
(
'Notification'
),
I18n
.
t
(
'EnterOTPRequest'
));
}
else
if
(
value
.
length
!=
4
)
{
showAlert
(
TYPE
.
WARN
,
I18n
.
t
(
'Notification'
),
I18n
.
t
(
'OTPInvalid'
));
}
else
{
props
.
showLoading
();
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
,
});
if
(
res1
.
data
.
code
==
200
)
{
let
res
;
if
(
props
.
route
.
params
.
type
==
'DEPOSIT'
)
{
const
{
amount
,
notes
}
=
props
.
route
.
params
;
res
=
await
walletDeposit
({
amount
,
platform
:
Platform
.
OS
,
notes
,
fee
:
0
,
});
}
else
{
const
{
src
,
receiving_account
,
amount
,
notes
}
=
props
.
route
.
params
;
res
=
await
widthDraw
({
src
,
receiving_account
,
amount
,
platform
:
Platform
.
OS
,
notes
,
fee
:
0
,
});
}
const
[
value
,
setValue
]
=
useState
(
props
.
route
.
params
.
otp
);
const
[
progress
,
setProgress
]
=
useState
(
1
);
const
[
isReset
,
setReset
]
=
useState
(
false
);
const
navigate
=
useNavigation
();
useEffect
(()
=>
{
setValue
(
props
.
route
.
params
.
otp
);
},
[
props
.
route
.
params
.
otp
]);
const
confirm
=
async
()
=>
{
if
(
!
value
)
{
showAlert
(
TYPE
.
WARN
,
I18n
.
t
(
'Notification'
),
I18n
.
t
(
'EnterOTPRequest'
));
}
else
if
(
value
.
length
!=
4
)
{
showAlert
(
TYPE
.
WARN
,
I18n
.
t
(
'Notification'
),
I18n
.
t
(
'OTPInvalid'
));
}
else
{
props
.
showLoading
();
let
res1
=
await
verifyOTPApi
({
platform
:
Platform
.
OS
,
receiver_name
:
props
.
user
.
email
,
otp
:
encryptRSAString
(
value
),
type
:
props
.
route
.
params
.
type
==
'DEPOSIT'
?
OTP_TYPE
.
CUSTOMER_REQUEST_DEPOSIT
:
OTP_TYPE
.
REQUEST_WITHDRAW
,
});
props
.
hideLoading
();
if
(
res
.
data
.
code
==
200
)
{
setTimeout
(()
=>
{
showAlert
(
TYPE
.
SUCCESS
,
I18n
.
t
(
'Notification'
),
res
.
data
.
message
)
;
if
(
res1
.
data
.
code
==
200
)
{
let
res
;
if
(
props
.
route
.
params
.
type
==
'DEPOSIT'
)
{
const
{
amount
,
notes
}
=
props
.
route
.
params
;
navigate
.
navigate
(
TABNAVIGATOR
);
},
500
);
}
else
{
showAlert
(
TYPE
.
ERROR
,
I18n
.
t
(
'Notification'
),
res
.
data
.
message
);
}
}
else
{
showAlert
(
TYPE
.
ERROR
,
I18n
.
t
(
'Notification'
),
res1
.
data
.
message
);
}
props
.
hideLoading
();
}
};
const
getNewOTP
=
async
()
=>
{
props
.
showLoading
();
const
res
=
await
getOTPApiSmartOTP
({
res
=
await
walletDeposit
({
amount
,
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
,
});
if
(
res
.
data
.
code
==
200
)
{
setValue
(
res
.
data
.
data
.
otp
);
setReset
(
!
isReset
);
notes
,
fee
:
0
,
});
}
else
{
showAlert
(
TYPE
.
ERROR
,
I18n
.
t
(
'Notification'
),
res
.
data
.
message
);
const
{
src
,
receiving_account
,
amount
,
notes
}
=
props
.
route
.
params
;
res
=
await
widthDraw
({
src
,
receiving_account
,
amount
,
platform
:
Platform
.
OS
,
notes
,
fee
:
0
,
});
}
props
.
hideLoading
();
};
if
(
res
.
data
.
code
==
200
)
{
setTimeout
(()
=>
{
showAlert
(
TYPE
.
SUCCESS
,
I18n
.
t
(
'Notification'
),
res
.
data
.
message
);
navigate
.
navigate
(
TABNAVIGATOR
);
},
500
);
}
else
{
showAlert
(
TYPE
.
ERROR
,
I18n
.
t
(
'Notification'
),
res
.
data
.
message
);
}
}
else
{
showAlert
(
TYPE
.
ERROR
,
I18n
.
t
(
'Notification'
),
res1
.
data
.
message
);
}
props
.
hideLoading
();
}
};
const
getNewOTP
=
async
()
=>
{
props
.
showLoading
();
const
res
=
await
getOTPApiSmartOTP
({
platform
:
Platform
.
OS
,
otp_by
:
props
.
user
.
email
,
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
(
decryptRSAString
(
res
.
data
.
data
.
otp
));
setReset
(
!
isReset
);
}
else
{
showAlert
(
TYPE
.
ERROR
,
I18n
.
t
(
'Notification'
),
res
.
data
.
message
);
}
props
.
hideLoading
();
};
const
updateProgress
=
(
count
)
=>
{
setProgress
(
count
>
0
?
count
/
300
:
0
);
};
const
updateProgress
=
(
count
)
=>
{
setProgress
(
count
>
0
?
count
/
300
:
0
);
};
return
<
SmartOTPView
value
=
{
value
}
progress
=
{
progress
}
confirm
=
{
confirm
}
isReset
=
{
isReset
}
getNewOTP
=
{
getNewOTP
}
updateProgress
=
{
updateProgress
}
setValue
=
{
setValue
}
/>
;
return
(
<
SmartOTPView
value
=
{
value
}
progress
=
{
progress
}
confirm
=
{
confirm
}
isReset
=
{
isReset
}
getNewOTP
=
{
getNewOTP
}
updateProgress
=
{
updateProgress
}
setValue
=
{
setValue
}
/
>
);
};
const
mapStateToProps
=
(
state
)
=>
{
return
{
user
:
state
.
userReducer
,
};
return
{
user
:
state
.
userReducer
,
};
};
export
default
connect
(
mapStateToProps
,
{
showLoading
,
hideLoading
})(
SmartOTP
);
src/apis/Functions/ConfirmOTPSmart.js
View file @
02afb8c4
...
...
@@ -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'
,
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment