diff --git a/zubhub_frontend/zubhub/public/locales/en/translation.json b/zubhub_frontend/zubhub/public/locales/en/translation.json index 605f31095..51afb1356 100644 --- a/zubhub_frontend/zubhub/public/locales/en/translation.json +++ b/zubhub_frontend/zubhub/public/locales/en/translation.json @@ -1190,11 +1190,5 @@ "text": "Get inspired by thousands of creators around the world.", "buttonLabel": "Get Started" } - }, - "sessionExpired": { - "heading": "Session Expired", - "title": "Your session has expired", - "text": "You will be redirected to the login page.", - "buttonLabel": "ok" } } \ No newline at end of file diff --git a/zubhub_frontend/zubhub/public/locales/hi/translation.json b/zubhub_frontend/zubhub/public/locales/hi/translation.json index e63fd8dc9..03af477a0 100644 --- a/zubhub_frontend/zubhub/public/locales/hi/translation.json +++ b/zubhub_frontend/zubhub/public/locales/hi/translation.json @@ -1092,11 +1092,5 @@ "text": "दुनिया भर के हजारों रचनाकारों से प्रेरणा लें।", "buttonLabel": "शुरू हो जाओ" } - }, - "sessionExpired": { - "heading": "सत्र समाप्त", - "title": "आपका सत्र समाप्त हो गया है", - "text": "आप लॉगिन पेज पर रीडायरेक्ट किए जाएंगे।", - "buttonLabel": "ठीक है" } } diff --git a/zubhub_frontend/zubhub/src/App.js b/zubhub_frontend/zubhub/src/App.js index 76d3858da..fd1c23b2c 100644 --- a/zubhub_frontend/zubhub/src/App.js +++ b/zubhub_frontend/zubhub/src/App.js @@ -10,9 +10,9 @@ import ProtectedRoute from './components/protected_route/ProtectedRoute'; import ZubhubAPI from '../src/api/api'; import { updateTheme } from './theme'; import ScrollToTop from './ScrollToTop'; -import SessionExpiredModal from './components/sessionExpired/sessionExpired'; const SearchResults = React.lazy(() => import('./views/search_results/SearchResults')); + const Signup = React.lazy(() => import('./views/signup/Signup')); const Login = React.lazy(() => import('./views/login/Login')); const PasswordReset = React.lazy(() => import('./views/password_reset/PasswordReset')); @@ -492,14 +492,7 @@ function App(props) { )} /> - ( - - - - )} - /> + ( diff --git a/zubhub_frontend/zubhub/src/components/modals/modal.styles.js b/zubhub_frontend/zubhub/src/components/modals/modal.styles.js index fcc2ff3df..3fd2ba277 100644 --- a/zubhub_frontend/zubhub/src/components/modals/modal.styles.js +++ b/zubhub_frontend/zubhub/src/components/modals/modal.styles.js @@ -22,8 +22,7 @@ export const modalStyles = theme => ({ dialogContainer: { '& .MuiDialog-paper': { overflow: 'visible !important' - }, - backdropFilter: 'blur(15px)', + } }, dialogPaper: { borderRadius: 8, diff --git a/zubhub_frontend/zubhub/src/components/sessionExpired/sessionExpired.Style.js b/zubhub_frontend/zubhub/src/components/sessionExpired/sessionExpired.Style.js deleted file mode 100644 index 393add147..000000000 --- a/zubhub_frontend/zubhub/src/components/sessionExpired/sessionExpired.Style.js +++ /dev/null @@ -1,85 +0,0 @@ -export const sessionExpiredStyle = theme => ({ - card: { - borderRadius: 12, - position: 'fixed', - top: '50%', - left: '50%', - transform: 'translate(-50%, -50%)', - boxShadow: theme.shadows[5], - overflow: 'hidden', - width: '90%', - zIndex: 1300, - [theme.breakpoints.up('sm')]: { - width: 500, - }, - }, - cardHeader: { - backgroundColor: theme.palette.primary.main, - color: theme.palette.common.white, - padding: theme.spacing(1), - [theme.breakpoints.up('sm')]: { - padding: theme.spacing(1, 2), - }, - display: 'flex', - justifyContent: 'space-between', - alignItems: 'center', - }, - cardContent: { - padding: theme.spacing(1), - [theme.breakpoints.up('sm')]: { - padding: theme.spacing(2), - }, - display: 'flex', - flexDirection: 'column', - alignItems: 'center', - }, - closeButton: { - cursor: 'pointer', - color: theme.palette.common.white, - }, - iconWrapper: { - marginBottom: theme.spacing(2), - display: 'flex', - justifyContent: 'center', - }, - centerText: { - textAlign: 'center', - marginBottom: theme.spacing(1), - }, - modal: { - display: 'flex', - alignItems: 'center', - justifyContent: 'center', - width: '100vw', - height: '100vh', - backgroundColor: theme.palette.background.paper, - backdropFilter: 'blur(5px)', - }, - textDecorationNone: { - width: '100%', - marginTop: theme.spacing(2), - }, - customButtonStyle: { - backgroundColor: theme.palette.primary.main, - color: theme.palette.common.white, - '&:hover': { - backgroundColor: theme.palette.primary.main, - }, - }, - buttonContainer: { - display: 'flex', - justifyContent: 'center', - marginTop: theme.spacing(2), - }, - errorIcon: { - fontSize: 60, - color: 'var(--primary-color1)', - }, - titleStyle: { - fontSize: '1.2rem', - [theme.breakpoints.up('sm')]: { - fontSize: '1.5rem', - }, - fontWeight: 600, - }, -}); diff --git a/zubhub_frontend/zubhub/src/components/sessionExpired/sessionExpired.jsx b/zubhub_frontend/zubhub/src/components/sessionExpired/sessionExpired.jsx deleted file mode 100644 index 75d74b8cb..000000000 --- a/zubhub_frontend/zubhub/src/components/sessionExpired/sessionExpired.jsx +++ /dev/null @@ -1,70 +0,0 @@ -import React, { useState } from 'react'; -import { useTranslation } from 'react-i18next'; -import clsx from 'clsx'; -import { Card, CardContent, Typography, ErrorOutline } from '@material-ui/core'; -import { makeStyles } from '@material-ui/core/styles'; -import { useHistory, Link } from 'react-router-dom'; -import { sessionExpiredStyle } from './sessionExpired.Style'; -import Modal from '../modals/Modal'; -import CustomButton from '../button/Button'; -import CloseIcon from '@material-ui/icons/Close'; -import ErrorOutlineIcon from '@material-ui/icons/ErrorOutline'; - -const useStyles = makeStyles(sessionExpiredStyle); - -const SessionExpiredModal = () => { - const classes = useStyles(); - const [modalOpen, setModalOpen] = useState(true); - const history = useHistory(); - - const handleClose = () => { - setModalOpen(false); - history.push('/login'); - }; - const { t } = useTranslation(); - - return ( - - -
- {t(`sessionExpired.heading`)} - - - -
- -
- -
- - {t(`sessionExpired.title`)} - - - {t(`sessionExpired.text`)} - -
- - - {t(`sessionExpired.buttonLabel`)} - - -
-
-
-
- ); -}; - -export default SessionExpiredModal; diff --git a/zubhub_frontend/zubhub/src/store/actions/authActions.js b/zubhub_frontend/zubhub/src/store/actions/authActions.js index ea712509a..7036fa23c 100644 --- a/zubhub_frontend/zubhub/src/store/actions/authActions.js +++ b/zubhub_frontend/zubhub/src/store/actions/authActions.js @@ -88,7 +88,7 @@ export const logout = args => { */ export const getAuthUser = props => { return dispatch => { - return API.getAuthUser(props.auth.token) + return API.getAuthUser(props.auth.token) .then(res => { if (!res.id) { dispatch( @@ -121,7 +121,6 @@ export const getAuthUser = props => { }; }; - export const AccountStatus = args => { return () => { return API.getAccountStatus(args.token).catch(() => { diff --git a/zubhub_frontend/zubhub/src/views/PageWrapper.jsx b/zubhub_frontend/zubhub/src/views/PageWrapper.jsx index 514f2aee8..086f5c32e 100644 --- a/zubhub_frontend/zubhub/src/views/PageWrapper.jsx +++ b/zubhub_frontend/zubhub/src/views/PageWrapper.jsx @@ -111,12 +111,6 @@ function PageWrapper(props) { setPrevScrollPos(currentScrollPos); }, [prevScrollPos]); - useEffect(() => { - if (!props.auth.token) { - props.history.push('/session-expired') - } - }, [props.auth.token]) - useEffect(() => { window.addEventListener('scroll', handleScroll); return () => { @@ -124,23 +118,6 @@ function PageWrapper(props) { }; }, [handleScroll]); - const unprotectedRoutes = [ - '/', - '/signup', - '/login', - '/password-reset', - '/projects/:id', - '/ambassadors', - '/creators/:username', - '/privacy_policy', - '/terms_of_use', - '/about', - '/challenge', - '/email-confirm', - '/password-reset-confirm', - '/session-expired' - ]; - const throttledFetchOptions = useMemo( () => throttle(async (query, searchType) => { @@ -188,6 +165,19 @@ function PageWrapper(props) { throttledFetchOptions.cancel(); }, []); + useEffect(() => { + handleSetState({ loading: true }); + fetchHero(props) + .then(() => { + if (props.auth.token) { + return props.getAuthUser(props); + } + }) + .finally(() => { + handleSetState({ loading: false }); + }); + }, [props.auth.token]); + useEffect(() => { handleSetState(handleProfileMenuClose()); }, [trigger]); @@ -250,14 +240,42 @@ function PageWrapper(props) { {props.auth?.token ? {loading ? : props.children} : null} {!props.auth?.token && - !unprotectedRoutes.includes(props.match?.path) && ( + ![ + '/', + '/signup', + '/login', + '/projects/:id', + '/ambassadors', + '/creators/:username', + '/privacy_policy', + '/terms_of_use', + '/about', + '/challenge', + '/password-reset', + '/email-confirm', + '/password-reset-confirm' + ].includes(props.match?.path) && (
)}
{!props.auth?.token && - unprotectedRoutes.includes(props.match?.path) &&
{props.children}
} + [ + '/', + '/signup', + '/login', + '/password-reset', + '/projects/:id', + '/ambassadors', + '/creators/:username', + '/privacy_policy', + '/terms_of_use', + '/about', + '/challenge', + '/email-confirm', + '/password-reset-confirm' + ].includes(props.match?.path) &&
{props.children}
}