all repos — caroster @ 14703ccf1e17e3b9d925f9a5521fde681209f4ed

[Octree] Group carpool to your event https://caroster.io

redirect to about_link on logout
Hadrien Froger hadrien@octree.ch
Wed, 09 Sep 2020 09:26:39 +0100
commit

14703ccf1e17e3b9d925f9a5521fde681209f4ed

parent

ee31f8ea32ae67c14b88a82de8005742b4c92cb2

M app/src/containers/EventMenu/index.jsapp/src/containers/EventMenu/index.js

@@ -10,12 +10,14 @@

const EventMenu = ({anchorEl, setAnchorEl, actions = []}) => { const {t} = useTranslation(); const strapi = useStrapi(); + const [settings] = strapi.stores?.settings || [{}]; const {logout, authState} = useAuth(); const classes = useStyles(); - const [settings] = strapi.stores?.settings || [{}]; - const logoutMenuItem = authState?.user - ? {label: t('menu.logout'), onClick: logout, id: 'LogoutTabs'} - : null; + const logoutMenuItem = authState?.user && { + label: t('menu.logout'), + onClick: () => logout(settings['about_link']), + id: 'LogoutTabs', + }; const aboutMenuItem = { label: t('menu.about'), onClick: () => (window.location.href = settings['about_link']),
M app/src/containers/GenericMenu/index.jsapp/src/containers/GenericMenu/index.js

@@ -19,9 +19,11 @@ const {logout, authState} = useAuth();

const [settings] = strapi.stores?.settings || [{}]; const validActions = useMemo(() => actions.filter(Boolean), [actions]); - const logoutMenuItem = authState?.user - ? {label: t('menu.logout'), onClick: logout, id: 'LogoutTabs'} - : null; + const logoutMenuItem = authState?.user && { + label: t('menu.logout'), + onClick: () => logout(settings['about_link']), + id: 'LogoutTabs', + }; const aboutMenuItem = { label: t('menu.about'), onClick: () => (window.location.href = settings['about_link']),
M app/src/containers/Profile/index.jsapp/src/containers/Profile/index.js

@@ -11,7 +11,7 @@ import EditPassword from './EditPassword';

import {useToast} from '../../contexts/Toast'; import ProfileField from './ProfileField'; import {makeStyles} from '@material-ui/core'; - +import {useStrapi} from 'strapi-react-context'; const Profile = ({profile, updateProfile, logout}) => { const {t} = useTranslation(); const {addToast} = useToast();

@@ -24,6 +24,8 @@ const [email, setEmail] = useState(profile.email);

const [oldPassword, setOldPassword] = useState(''); const [newPassword, setNewPassword] = useState(''); const [errorPassword, setErrorPassword] = useState(''); + const strapi = useStrapi(); + const [settings] = strapi.stores?.settings || [{}]; const resetPassword = () => { setIsEditingPassword(false);

@@ -141,7 +143,11 @@ {t('profile.actions.change_password')}

</Button> )} {!isEditing && ( - <Button type="button" color="default" onClick={() => logout()}> + <Button + type="button" + color="default" + onClick={() => logout(settings['about_link'])} + > {t('profile.actions.logout')} </Button> )}
M app/src/pages/Profile.jsapp/src/pages/Profile.js

@@ -1,5 +1,5 @@

import React from 'react'; -import {useAuth} from 'strapi-react-context'; +import {useAuth, useStrapi} from 'strapi-react-context'; import Layout from '../layouts/Centered'; import {useTranslation} from 'react-i18next'; import {useHistory} from 'react-router-dom';

@@ -12,6 +12,8 @@ const history = useHistory();

const {t} = useTranslation(); const {logout, updateProfile} = useAuth(); const {profile} = useProfile(); + const strapi = useStrapi(); + const [settings] = strapi.stores?.settings || [{}]; const menuActions = [ {

@@ -33,7 +35,7 @@ <Layout menuTitle={t('profile.title')} menuActions={menuActions}>

<Profile profile={profile} updateProfile={updateProfile} - logout={logout} + logout={() => logout(settings['about_link'])} /> </Layout> );