mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 23:00:34 +00:00
feat: handle forbidden request error.
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import * as R from 'ramda';
|
import * as R from 'ramda';
|
||||||
|
|
||||||
import { AuthenticatedUser } from './AuthenticatedUser';
|
|
||||||
import { DashboardBoot } from '../../components';
|
import { DashboardBoot } from '../../components';
|
||||||
|
|
||||||
import withDashboard from '../../containers/Dashboard/withDashboard';
|
import withDashboard from '../../containers/Dashboard/withDashboard';
|
||||||
@@ -16,11 +15,10 @@ function PrivatePagesProviderComponent({
|
|||||||
children,
|
children,
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<AuthenticatedUser>
|
<React.Fragment>
|
||||||
<DashboardBoot />
|
<DashboardBoot />
|
||||||
|
|
||||||
{splashScreenCompleted ? children : null}
|
{splashScreenCompleted ? children : null}
|
||||||
</AuthenticatedUser>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,10 +14,14 @@ import { firstLettersArgs } from 'utils';
|
|||||||
import { useAuthActions } from 'hooks/state';
|
import { useAuthActions } from 'hooks/state';
|
||||||
|
|
||||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
import { compose } from 'utils';
|
|
||||||
import withSubscriptions from '../../containers/Subscriptions/withSubscriptions';
|
import withSubscriptions from '../../containers/Subscriptions/withSubscriptions';
|
||||||
import { useAuthenticatedUser } from './AuthenticatedUser';
|
|
||||||
|
|
||||||
|
import { useAuthenticatedAccount } from 'hooks/query'
|
||||||
|
import { compose } from 'utils';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dashboard topbar user.
|
||||||
|
*/
|
||||||
function DashboardTopbarUser({
|
function DashboardTopbarUser({
|
||||||
openDialog,
|
openDialog,
|
||||||
|
|
||||||
@@ -28,7 +32,7 @@ function DashboardTopbarUser({
|
|||||||
const { setLogout } = useAuthActions();
|
const { setLogout } = useAuthActions();
|
||||||
|
|
||||||
// Retrieve authenticated user information.
|
// Retrieve authenticated user information.
|
||||||
const { user } = useAuthenticatedUser();
|
const { data: user } = useAuthenticatedAccount();
|
||||||
|
|
||||||
const onClickLogout = () => {
|
const onClickLogout = () => {
|
||||||
setLogout();
|
setLogout();
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { Button, Popover, Menu, Position } from '@blueprintjs/core';
|
|||||||
import Icon from 'components/Icon';
|
import Icon from 'components/Icon';
|
||||||
import { compose, firstLettersArgs } from 'utils';
|
import { compose, firstLettersArgs } from 'utils';
|
||||||
import withCurrentOrganization from '../../containers/Organization/withCurrentOrganization';
|
import withCurrentOrganization from '../../containers/Organization/withCurrentOrganization';
|
||||||
import { useAuthenticatedUser } from '../Dashboard/AuthenticatedUser';
|
import { useAuthenticatedAccount } from '../../hooks/query';
|
||||||
|
|
||||||
// Popover modifiers.
|
// Popover modifiers.
|
||||||
const POPOVER_MODIFIERS = {
|
const POPOVER_MODIFIERS = {
|
||||||
@@ -18,7 +18,7 @@ function SidebarHead({
|
|||||||
organization,
|
organization,
|
||||||
}) {
|
}) {
|
||||||
// Retrieve authenticated user information.
|
// Retrieve authenticated user information.
|
||||||
const { user } = useAuthenticatedUser();
|
const { data: user } = useAuthenticatedAccount();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="sidebar__head">
|
<div className="sidebar__head">
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import React from 'react';
|
|
||||||
import { Intent } from '@blueprintjs/core';
|
import { Intent } from '@blueprintjs/core';
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
import { useHistory } from 'react-router-dom';
|
|
||||||
import AppToaster from 'components/AppToaster';
|
import AppToaster from 'components/AppToaster';
|
||||||
|
|
||||||
import withGlobalErrors from './withGlobalErrors';
|
import withGlobalErrors from './withGlobalErrors';
|
||||||
@@ -30,7 +28,6 @@ function GlobalErrors({
|
|||||||
toastKeySessionExpired,
|
toastKeySessionExpired,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (globalErrors.session_expired) {
|
if (globalErrors.session_expired) {
|
||||||
toastKeySomethingWrong = AppToaster.show(
|
toastKeySomethingWrong = AppToaster.show(
|
||||||
{
|
{
|
||||||
@@ -43,6 +40,18 @@ function GlobalErrors({
|
|||||||
toastKeySomethingWrong,
|
toastKeySomethingWrong,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (globalErrors.access_denied) {
|
||||||
|
toastKeySomethingWrong = AppToaster.show(
|
||||||
|
{
|
||||||
|
message: 'You do not have permissions to access this page.',
|
||||||
|
intent: Intent.DANGER,
|
||||||
|
onDismiss: () => {
|
||||||
|
globalErrorsSet({ access_denied: false });
|
||||||
|
},
|
||||||
|
},
|
||||||
|
toastKeySomethingWrong,
|
||||||
|
);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user