diff --git a/src/App.js b/src/App.js index 2f9b947..4ba5928 100644 --- a/src/App.js +++ b/src/App.js @@ -113,6 +113,24 @@ const App = () => { } /> + + } + /> + + } + /> {KeyCloakService.isLoggedIn() ? ( <> } /> diff --git a/src/pages/PolicyPrivacy.js b/src/pages/PolicyPrivacy.js index 8727508..c3555d9 100644 --- a/src/pages/PolicyPrivacy.js +++ b/src/pages/PolicyPrivacy.js @@ -4,9 +4,7 @@ import styled from 'styled-components'; import { Body, H1, H2, Medium } from '../utils/fonts'; import CircleNumber from '../components/generic/CircleNumber'; import Button from '../components/generic/Button'; -import theme from '../utils/theme'; import KeyCloakService from '../services/KeyCloakService'; -import { ROOT_URL } from '../utils/globals'; const PolicyPrivacyStyle = styled(FlexColumn)` justify-content: flex-start; @@ -41,10 +39,13 @@ const PolicyPrivacyStyle = styled(FlexColumn)` const PolicyPrivacy = (props) => { React.useEffect(() => { - props.popUpMessageHandler( - 'Policy privacy', - 'Please read the service policy below and accept its terms and conditions to create an account using the button at the bottom of the page.' - ); + const privacyPolicyAccept = localStorage.getItem('privacyPolicy'); + if (privacyPolicyAccept !== 'accept') { + props.popUpMessageHandler( + 'Policy privacy', + 'Please read the service policy below and accept its terms and conditions to create an account using the button at the bottom of the page.' + ); + } // eslint-disable-next-line react-hooks/exhaustive-deps }, []); @@ -63,35 +64,34 @@ const PolicyPrivacy = (props) => { KeyCloakService.doRegister(); }; + const doLogin = () => { + localStorage.setItem('privacyPolicy', 'accept'); + KeyCloakService.doLogin(); + }; + const renderButtons = () => { - return ( - - - - - ); + let acceptHandler = null; + let buttonHandler = null; + if (props.beforeLogin) buttonHandler = doLogin; + if (props.beforeRegister) { + acceptHandler = () => doRegister; + buttonHandler = () => { + props.popUpMessageHandler( + 'Reminder', + 'Remember to check your spam mailbox to confirm your account.', + acceptHandler + ); + }; + } + if (props.beforeLogin || props.beforeRegister) { + return ( + + + + ); + } }; return ( diff --git a/src/services/KeyCloakService.js b/src/services/KeyCloakService.js index a9c9ecc..d394322 100644 --- a/src/services/KeyCloakService.js +++ b/src/services/KeyCloakService.js @@ -28,7 +28,7 @@ const initKeycloak = (onAuthenticatedCallback) => { const doLogin = () => { const privacyPolicyAccept = localStorage.getItem('privacyPolicy'); if (privacyPolicyAccept !== 'accept') { - window.location = `${ROOT_URL}${POLICY_PRIVACY_PAGE}`; + window.location = `${ROOT_URL}${POLICY_PRIVACY_PAGE}/login`; } else { _kc.login(); } @@ -44,7 +44,7 @@ const getToken = () => _kc.token; const doRegister = () => { const privacyPolicyAccept = localStorage.getItem('privacyPolicy'); if (privacyPolicyAccept !== 'accept') { - window.location = `${ROOT_URL}${POLICY_PRIVACY_PAGE}`; + window.location = `${ROOT_URL}${POLICY_PRIVACY_PAGE}/register`; } else { _kc.register(); }