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
9f568dc5
Commit
9f568dc5
authored
Jun 01, 2021
by
Nguyễn Thị Thúy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
logout when session end
parent
113cb583
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
106 additions
and
16 deletions
+106
-16
Login.js
src/Screens/Authen/Login.js
+1
-0
helpers.js
src/apis/helpers.js
+82
-8
en.js
src/helper/i18/locales/en.js
+1
-0
vn.js
src/helper/i18/locales/vn.js
+1
-0
TabNavigation.js
src/routers/TabNavigation.js
+21
-8
No files found.
src/Screens/Authen/Login.js
View file @
9f568dc5
...
...
@@ -50,6 +50,7 @@ const Login = (props) => {
};
useEffect
(()
=>
{
props
.
hideLoading
();
getAccount
();
getTokenDevice
();
},
[]);
...
...
src/apis/helpers.js
View file @
9f568dc5
import
KEY
from
'../assets/AsynStorage'
;
import
axios
from
'axios'
;
import
AsyncStorage
from
'@react-native-community/async-storage'
;
import
{
showAlert
,
TYPE
}
from
'../components/DropdownAlert/index'
;
import
I18n
from
'../helper/i18/i18n'
;
import
{
DeviceEventEmitter
}
from
'react-native'
;
axios
.
defaults
.
timeout
=
10000
;
...
...
@@ -22,8 +25,22 @@ export async function GetData(url, data) {
};
console
.
log
(
'My request'
,
myRequest
);
return
await
axios
(
myRequest
)
.
then
((
response
)
=>
response
)
.
then
((
response
)
=>
response
)
.
then
((
response
)
=>
{
if
(
response
.
data
?.
code
===
401
)
{
logout
();
return
;
}
else
{
return
response
;
}
})
.
then
((
response
)
=>
{
if
(
response
.
data
?.
code
===
401
)
{
logout
();
return
;
}
else
{
return
response
;
}
})
.
catch
((
error
)
=>
{
console
.
log
(
error
.
request
);
const
err
=
{
...
...
@@ -47,8 +64,22 @@ export async function PostLogin(url, json) {
};
console
.
log
(
'post data mobile'
,
myRequest
);
return
await
axios
(
myRequest
)
.
then
((
response
)
=>
response
)
.
then
((
response
)
=>
response
)
.
then
((
response
)
=>
{
if
(
response
.
data
?.
code
===
401
)
{
logout
();
return
;
}
else
{
return
response
;
}
})
.
then
((
response
)
=>
{
if
(
response
.
data
?.
code
===
401
)
{
logout
();
return
;
}
else
{
return
response
;
}
})
.
catch
((
error
)
=>
{
console
.
log
(
error
);
const
err
=
{
...
...
@@ -75,8 +106,22 @@ export async function PostData(url, json, isAuth = true) {
};
console
.
log
(
'post data mobile'
,
myRequest
);
return
await
axios
(
myRequest
)
.
then
((
response
)
=>
response
)
.
then
((
response
)
=>
response
)
.
then
((
response
)
=>
{
if
(
response
.
data
?.
code
===
401
)
{
logout
();
return
;
}
else
{
return
response
;
}
})
.
then
((
response
)
=>
{
if
(
response
.
data
?.
code
===
401
)
{
logout
();
return
;
}
else
{
return
response
;
}
})
.
catch
((
error
)
=>
{
console
.
log
(
error
.
request
);
const
err
=
{
...
...
@@ -111,11 +156,21 @@ export async function PostFormData(url, data) {
return
await
axios
(
myRequest
)
.
then
((
response
)
=>
{
clearTimeout
(
timeout
);
if
(
response
.
data
?.
code
===
401
)
{
logout
();
return
;
}
else
{
return
response
;
}
})
.
then
((
response
)
=>
{
clearTimeout
(
timeout
);
if
(
response
.
data
?.
code
===
401
)
{
logout
();
return
;
}
else
{
return
response
;
}
})
.
catch
((
error
)
=>
{
clearTimeout
(
timeout
);
...
...
@@ -148,8 +203,22 @@ export async function PutData(url, json, isAuth = true) {
};
console
.
log
(
'PutData'
,
myRequest
);
return
await
axios
(
myRequest
)
.
then
((
response
)
=>
response
)
.
then
((
response
)
=>
response
)
.
then
((
response
)
=>
{
if
(
response
.
data
?.
code
===
401
)
{
logout
();
return
;
}
else
{
return
response
;
}
})
.
then
((
response
)
=>
{
if
(
response
.
data
?.
code
===
401
)
{
logout
();
return
;
}
else
{
return
response
;
}
})
.
catch
((
error
)
=>
{
console
.
log
(
error
.
request
);
const
err
=
{
...
...
@@ -159,3 +228,8 @@ export async function PutData(url, json, isAuth = true) {
return
err
;
});
}
export
function
logout
()
{
showAlert
(
TYPE
.
ERROR
,
I18n
.
t
(
'Notification'
),
I18n
.
t
(
'LoginSessionEnd'
));
DeviceEventEmitter
.
emit
(
'logout'
);
}
src/helper/i18/locales/en.js
View file @
9f568dc5
...
...
@@ -289,4 +289,5 @@ export default {
WarnMinReqestWithdraw
:
'The withdrawal amount must be more than 1 million dong'
,
Overtime
:
'Overtime OTP'
,
LoginSessionEnd
:
'Login session end, please login again'
,
};
src/helper/i18/locales/vn.js
View file @
9f568dc5
...
...
@@ -289,4 +289,5 @@ export default {
FirstEscrow
:
'Ký quỹ ban đầu (VNĐ) '
,
WarnMinReqestWithdraw
:
'Số tiền rút phải lớn hơn 1 triệu đồng'
,
Overtime
:
'Mã OTP hết hạn sử dụng'
,
LoginSessionEnd
:
"Hết phiên đăng nhập, vui lòng đăng nhập lại"
,
};
src/routers/TabNavigation.js
View file @
9f568dc5
import
React
,
{
useEffect
}
from
'react'
;
import
{
View
,
Text
,
Linking
,
Image
}
from
'react-native'
;
import
{
View
,
Text
,
Linking
,
Image
,
DeviceEventEmitter
}
from
'react-native'
;
import
{
createBottomTabNavigator
}
from
'@react-navigation/bottom-tabs'
;
import
Icon
from
'react-native-vector-icons/FontAwesome5'
;
import
Ionicons
from
'react-native-vector-icons/Ionicons'
;
...
...
@@ -23,7 +23,7 @@ import {changeLanguage} from '../actions/language';
import
KEY
from
'../assets/AsynStorage'
;
import
AsyncStorage
from
'@react-native-community/async-storage'
;
import
{
DETAILNEW
}
from
'../routers/ScreenNames'
;
import
{
getHeight
,
getWidth
}
from
'../Config/Functions'
;
import
{
getHeight
,
getWidth
,
logout
}
from
'../Config/Functions'
;
const
Tab
=
createBottomTabNavigator
();
...
...
@@ -40,14 +40,25 @@ const TabNavigator = (props) => {
setTimeout
(()
=>
{
showPopUp
();
},
3000
);
let
logoutListener
=
DeviceEventEmitter
.
addListener
(
'logout'
,
(
e
)
=>
{
console
.
log
(
'run in to logout'
);
logout
(
navigate
);
});
return
()
=>
{
logoutListener
.
remove
();
};
},
[]);
const
checkDeepking
=
()
=>
{
Linking
.
getInitialURL
().
then
((
url
)
=>
{
if
(
url
)
deeplinkScreen
(
url
);
if
(
url
)
{
deeplinkScreen
(
url
);
}
});
Linking
.
addEventListener
(
'url'
,
(
url
)
=>
{
if
(
url
)
handleOpenURL
(
url
);
if
(
url
)
{
handleOpenURL
(
url
);
}
});
};
...
...
@@ -78,7 +89,9 @@ const TabNavigator = (props) => {
const
setInitLanguage
=
async
()
=>
{
const
laguage
=
await
AsyncStorage
.
getItem
(
KEY
.
LANGUAGE
);
if
(
laguage
)
props
.
changeLanguage
(
laguage
);
if
(
laguage
)
{
props
.
changeLanguage
(
laguage
);
}
setLocation
(
I18n
,
laguage
);
};
...
...
@@ -104,7 +117,7 @@ const TabNavigator = (props) => {
options
=
{{
tabBarLabel
:
'Overview'
,
tabBarIcon
:
({
color
,
size
})
=>
(
<
Icon
name
=
"landmark"
size
=
{
size
}
color
=
{
color
}
/
>
<
Icon
name
=
"landmark"
size
=
{
size
}
color
=
{
color
}
/
>
),
}}
/
>
...
...
@@ -128,7 +141,7 @@ const TabNavigator = (props) => {
name
=
"Pay"
component
=
{
PayScreenComponent
}
options
=
{{
tabBarButton
:
()
=>
<
PlussModal
/>
,
tabBarButton
:
()
=>
<
PlussModal
/>
,
}}
/
>
...
...
@@ -153,7 +166,7 @@ const TabNavigator = (props) => {
options
=
{{
tabBarLabel
:
props
.
language
.
language
==
'vi'
?
'Tin tức'
:
'News'
,
tabBarIcon
:
({
color
,
size
})
=>
(
<
Ionicons
name
=
"newspaper-outline"
size
=
{
size
}
color
=
{
color
}
/
>
<
Ionicons
name
=
"newspaper-outline"
size
=
{
size
}
color
=
{
color
}
/
>
),
}}
/
>
...
...
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