remove automatic logout after 15min
This commit is contained in:
parent
c74f427fd5
commit
02f0e1cf3c
@ -63,9 +63,6 @@ export const loadUser = () => (dispatch) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var logoutTimerId;
|
|
||||||
const timeToLogout = 14.9 * 60 * 1000; // nearly 15 minutes corresponding to the API
|
|
||||||
|
|
||||||
// Login user
|
// Login user
|
||||||
export const login =
|
export const login =
|
||||||
({ email, password }) =>
|
({ email, password }) =>
|
||||||
@ -84,10 +81,6 @@ export const login =
|
|||||||
axios
|
axios
|
||||||
.post(`${process.env.REACT_APP_BLOCKLY_API}/user`, body, config)
|
.post(`${process.env.REACT_APP_BLOCKLY_API}/user`, body, config)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
// Logout automatically if refreshToken "expired"
|
|
||||||
const logoutTimer = () =>
|
|
||||||
setTimeout(() => dispatch(logout()), timeToLogout);
|
|
||||||
logoutTimerId = logoutTimer();
|
|
||||||
dispatch(setLanguage(res.data.user.language));
|
dispatch(setLanguage(res.data.user.language));
|
||||||
dispatch({
|
dispatch({
|
||||||
type: LOGIN_SUCCESS,
|
type: LOGIN_SUCCESS,
|
||||||
@ -144,7 +137,6 @@ export const logout = () => (dispatch) => {
|
|||||||
}
|
}
|
||||||
dispatch(setLanguage(locale));
|
dispatch(setLanguage(locale));
|
||||||
dispatch(returnSuccess(res.data.message, res.status, "LOGOUT_SUCCESS"));
|
dispatch(returnSuccess(res.data.message, res.status, "LOGOUT_SUCCESS"));
|
||||||
clearTimeout(logoutTimerId);
|
|
||||||
},
|
},
|
||||||
error: (err) => {
|
error: (err) => {
|
||||||
dispatch(
|
dispatch(
|
||||||
@ -165,7 +157,6 @@ export const logout = () => (dispatch) => {
|
|||||||
type: GET_STATUS,
|
type: GET_STATUS,
|
||||||
payload: status,
|
payload: status,
|
||||||
});
|
});
|
||||||
clearTimeout(logoutTimerId);
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
axios
|
axios
|
||||||
@ -222,10 +213,6 @@ export const authInterceptor = () => (dispatch, getState) => {
|
|||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
clearTimeout(logoutTimerId);
|
|
||||||
const logoutTimer = () =>
|
|
||||||
setTimeout(() => dispatch(logout()), timeToLogout);
|
|
||||||
logoutTimerId = logoutTimer();
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: REFRESH_TOKEN_SUCCESS,
|
type: REFRESH_TOKEN_SUCCESS,
|
||||||
payload: res.data,
|
payload: res.data,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user