feat: implement revoke access token with RQ
This commit is contained in:
@@ -4,22 +4,30 @@ import PropTypes from 'prop-types';
|
||||
import MenuItem from '@mui/material/MenuItem';
|
||||
import Menu from '@mui/material/Menu';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
import Can from 'components/Can';
|
||||
import apolloClient from 'graphql/client';
|
||||
import * as URLS from 'config/urls';
|
||||
import useAuthentication from 'hooks/useAuthentication';
|
||||
import useFormatMessage from 'hooks/useFormatMessage';
|
||||
import useRevokeAccessToken from 'hooks/useRevokeAccessToken';
|
||||
function AccountDropdownMenu(props) {
|
||||
const formatMessage = useFormatMessage();
|
||||
const authentication = useAuthentication();
|
||||
const token = authentication.token;
|
||||
const navigate = useNavigate();
|
||||
const revokeAccessTokenMutation = useRevokeAccessToken(token);
|
||||
const { open, onClose, anchorEl, id } = props;
|
||||
|
||||
const logout = async () => {
|
||||
revokeAccessTokenMutation.mutate();
|
||||
|
||||
authentication.removeToken();
|
||||
await apolloClient.clearStore();
|
||||
onClose();
|
||||
navigate(URLS.LOGIN);
|
||||
};
|
||||
|
||||
return (
|
||||
<Menu
|
||||
anchorEl={anchorEl}
|
||||
|
Reference in New Issue
Block a user