From c74f427fd58e32c67aba7833eb7dec0f7d523af7 Mon Sep 17 00:00:00 2001 From: fbruc03 <65135023+fbruc03@users.noreply.github.com> Date: Fri, 23 Sep 2022 14:26:52 +0200 Subject: [PATCH 1/2] update outdated npm packages --- package.json | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 55f3f5b..3093381 100644 --- a/package.json +++ b/package.json @@ -10,39 +10,39 @@ "@blockly/plugin-typed-variable-modal": "^4.0.5", "@blockly/workspace-backpack": "^2.0.12", "@blockly/zoom-to-fit": "^2.0.14", - "@fortawesome/fontawesome-svg-core": "^1.2.30", - "@fortawesome/free-solid-svg-icons": "^5.14.0", - "@fortawesome/react-fontawesome": "^0.1.11", - "@material-ui/core": "^4.11.0", + "@fortawesome/fontawesome-svg-core": "^1.2.36", + "@fortawesome/free-solid-svg-icons": "^5.15.4", + "@fortawesome/react-fontawesome": "^0.1.19", + "@material-ui/core": "^4.12.4", "@monaco-editor/react": "^4.3.1", - "@sentry/react": "^6.0.0", - "@sentry/tracing": "^6.0.0", - "@testing-library/jest-dom": "^5.16.1", - "@testing-library/react": "^12.1.2", + "@sentry/react": "^6.19.7", + "@sentry/tracing": "^6.19.7", + "@testing-library/jest-dom": "^5.16.5", + "@testing-library/react": "^12.1.5", "@testing-library/user-event": "^7.2.1", "axios": "^0.22.0", "blockly": "^8.0.3", - "file-saver": "^2.0.2", + "file-saver": "^2.0.5", "markdown-it": "^12.3.2", "mnemonic-id": "^3.2.7", - "moment": "^2.28.0", + "moment": "^2.29.4", "prismjs": "^1.27.0", "qrcode.react": "^3.1.0", "react": "^17.0.2", "react-cookie-consent": "^7.2.1", "react-dom": "^17.0.2", "react-markdown": "^8.0.0", - "react-markdown-editor-lite": "^1.3.2", + "react-markdown-editor-lite": "^1.3.3", "react-mde": "^11.5.0", "react-rating-stars-component": "^2.2.0", - "react-redux": "^7.2.4", - "react-router-dom": "^5.2.0", + "react-redux": "^7.2.9", + "react-router-dom": "^5.3.3", "react-scripts": "^5.0.0", "react-share": "^4.4.0", "react-spinners": "^0.13.3", "reactour": "^1.18.7", - "redux": "^4.0.5", - "redux-thunk": "^2.3.0", + "redux": "^4.2.0", + "redux-thunk": "^2.4.1", "remark-gemoji": "^7.0.1", "remark-gfm": "^3.0.1", "styled-components": "^4.4.1", From 02f0e1cf3c40a660d3e165b05e4232412e6e59b1 Mon Sep 17 00:00:00 2001 From: fbruc03 <65135023+fbruc03@users.noreply.github.com> Date: Tue, 27 Sep 2022 17:16:23 +0200 Subject: [PATCH 2/2] remove automatic logout after 15min --- src/actions/authActions.js | 105 ++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 59 deletions(-) diff --git a/src/actions/authActions.js b/src/actions/authActions.js index 04a2265..086d703 100644 --- a/src/actions/authActions.js +++ b/src/actions/authActions.js @@ -63,63 +63,56 @@ export const loadUser = () => (dispatch) => { }); }; -var logoutTimerId; -const timeToLogout = 14.9 * 60 * 1000; // nearly 15 minutes corresponding to the API - // Login user export const login = ({ email, password }) => - (dispatch) => { - dispatch({ - type: USER_LOADING, - }); - // Headers - const config = { - headers: { - "Content-Type": "application/json", - }, - }; - // Request Body - const body = JSON.stringify({ email, password }); - axios - .post(`${process.env.REACT_APP_BLOCKLY_API}/user`, body, config) - .then((res) => { - // Logout automatically if refreshToken "expired" - const logoutTimer = () => - setTimeout(() => dispatch(logout()), timeToLogout); - logoutTimerId = logoutTimer(); - dispatch(setLanguage(res.data.user.language)); - dispatch({ - type: LOGIN_SUCCESS, - payload: res.data, - }); - dispatch({ - type: GET_STATUS, - payload: res.data.user.status, - }); - dispatch(returnSuccess(res.data.message, res.status, "LOGIN_SUCCESS")); - }) - .catch((err) => { - dispatch( - returnErrors( - err.response.data.message, - err.response.status, - "LOGIN_FAIL" - ) - ); - dispatch({ - type: LOGIN_FAIL, - }); - var status = []; - if (window.localStorage.getItem("status")) { - status = JSON.parse(window.localStorage.getItem("status")); - } - dispatch({ - type: GET_STATUS, - payload: status, - }); + (dispatch) => { + dispatch({ + type: USER_LOADING, }); - }; + // Headers + const config = { + headers: { + "Content-Type": "application/json", + }, + }; + // Request Body + const body = JSON.stringify({ email, password }); + axios + .post(`${process.env.REACT_APP_BLOCKLY_API}/user`, body, config) + .then((res) => { + dispatch(setLanguage(res.data.user.language)); + dispatch({ + type: LOGIN_SUCCESS, + payload: res.data, + }); + dispatch({ + type: GET_STATUS, + payload: res.data.user.status, + }); + dispatch(returnSuccess(res.data.message, res.status, "LOGIN_SUCCESS")); + }) + .catch((err) => { + dispatch( + returnErrors( + err.response.data.message, + err.response.status, + "LOGIN_FAIL" + ) + ); + dispatch({ + type: LOGIN_FAIL, + }); + var status = []; + if (window.localStorage.getItem("status")) { + status = JSON.parse(window.localStorage.getItem("status")); + } + dispatch({ + type: GET_STATUS, + payload: status, + }); + }); + }; // Logout User export const logout = () => (dispatch) => { @@ -144,7 +137,6 @@ export const logout = () => (dispatch) => { } dispatch(setLanguage(locale)); dispatch(returnSuccess(res.data.message, res.status, "LOGOUT_SUCCESS")); - clearTimeout(logoutTimerId); }, error: (err) => { dispatch( @@ -165,7 +157,6 @@ export const logout = () => (dispatch) => { type: GET_STATUS, payload: status, }); - clearTimeout(logoutTimerId); }, }; axios @@ -222,10 +213,6 @@ export const authInterceptor = () => (dispatch, getState) => { }) .then((res) => { if (res.status === 200) { - clearTimeout(logoutTimerId); - const logoutTimer = () => - setTimeout(() => dispatch(logout()), timeToLogout); - logoutTimerId = logoutTimer(); dispatch({ type: REFRESH_TOKEN_SUCCESS, payload: res.data,