feat: Redirect on unpublished share access (#3760)
* feat(WIP): Redirect on unpublished shares * feat[WIP]: add redirect with test notice * Revert to `Login` display, no redirects
This commit is contained in:
committed by
GitHub
parent
465a8bd505
commit
66dbcde29b
@@ -4,6 +4,7 @@ import * as React from "react";
|
||||
import { Helmet } from "react-helmet";
|
||||
import { RouteComponentProps, useLocation } from "react-router-dom";
|
||||
import { useTheme } from "styled-components";
|
||||
import { setCookie } from "tiny-cookie";
|
||||
import DocumentModel from "~/models/Document";
|
||||
import Error404 from "~/scenes/Error404";
|
||||
import ErrorOffline from "~/scenes/ErrorOffline";
|
||||
@@ -11,7 +12,8 @@ import Layout from "~/components/Layout";
|
||||
import Sidebar from "~/components/Sidebar/Shared";
|
||||
import useStores from "~/hooks/useStores";
|
||||
import { NavigationNode } from "~/types";
|
||||
import { OfflineError } from "~/utils/errors";
|
||||
import { AuthorizationError, OfflineError } from "~/utils/errors";
|
||||
import Login from "../Login";
|
||||
import Document from "./components/Document";
|
||||
import Loading from "./components/Loading";
|
||||
|
||||
@@ -105,7 +107,14 @@ function SharedDocumentScene(props: Props) {
|
||||
}, [documents, documentSlug, shareId, ui]);
|
||||
|
||||
if (error) {
|
||||
return error instanceof OfflineError ? <ErrorOffline /> : <Error404 />;
|
||||
if (error instanceof OfflineError) {
|
||||
return <ErrorOffline />;
|
||||
} else if (error instanceof AuthorizationError) {
|
||||
setCookie("postLoginRedirectPath", props.location.pathname);
|
||||
return <Login />;
|
||||
} else {
|
||||
return <Error404 />;
|
||||
}
|
||||
}
|
||||
|
||||
if (!response) {
|
||||
|
||||
Reference in New Issue
Block a user