diff --git a/README.md b/README.md index 18aad91..6623309 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ This should get the template working in development mode. - ~~sign up~~ - ~~validate email~~ - ~~login (with cookies)~~ - - logout (with cookies) + - ~~logout (with cookies)~~ - account deletion and management - annoying "This site uses cookies" message - Administration Panel diff --git a/client/components/pages/login.jsx b/client/components/pages/login.jsx index 0565e77..eb2dc3e 100644 --- a/client/components/pages/login.jsx +++ b/client/components/pages/login.jsx @@ -25,7 +25,7 @@ const LogIn = props => { handleSubmit(emailElement.value, passwordElement.value) .then(res => res ? alert(res) : null) .then(() => emailElement.value = passwordElement.value = '') //clear input - .then(() => props.history.push('/')) + .then(() => { window.location.reload(true); }) //BUFGIX: force reload of the header element .catch(e => console.error(e)) ; } diff --git a/client/components/panels/header.jsx b/client/components/panels/header.jsx index 4d0340c..e5f70a1 100644 --- a/client/components/panels/header.jsx +++ b/client/components/panels/header.jsx @@ -1,9 +1,11 @@ import React from 'react'; +import { useCookies } from 'react-cookie'; const Visitor = () => { return (
); @@ -13,16 +15,34 @@ const Member = () => { return ( ); }; +const logout = async () => { + await fetch('/api/accounts/logout') + .catch(e => console.error(e)) + ; +}; + const Header = () => { + const [cookies, setCookie] = useCookies(['loggedin']); + + let Options; + + //check for logged in/out status + if (cookies['loggedin']) { + Options = Member; + } else { + Options = Visitor; + } + return (