Web: Added portal recovery pages to the login page.
This commit is contained in:
parent
508ef81440
commit
7b55fe5a68
@ -474,7 +474,7 @@ const Shell = ({ items = [], page = "home", ...rest }) => {
|
||||
path={"/portal-settings"}
|
||||
component={PortalSettingsRoute}
|
||||
/>
|
||||
<PrivateRoute
|
||||
<PublicRoute
|
||||
path={"/preparation-portal"}
|
||||
component={PreparationPortalRoute}
|
||||
/>
|
||||
|
@ -136,10 +136,7 @@ const PrivateRoute = ({ component: Component, ...rest }) => {
|
||||
);
|
||||
}
|
||||
|
||||
if (tenantStatus !== TenantStatus.PortalRestore && isPortalUrl) {
|
||||
return window.location.replace("/");
|
||||
}
|
||||
|
||||
|
||||
if (
|
||||
isNotPaidPeriod &&
|
||||
isLoaded &&
|
||||
|
@ -3,15 +3,26 @@ import React from "react";
|
||||
import { Redirect, Route } from "react-router-dom";
|
||||
import AppLoader from "../AppLoader";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import { TenantStatus } from "../../constants";
|
||||
|
||||
export const PublicRoute = ({ component: Component, ...rest }) => {
|
||||
const { wizardCompleted, isAuthenticated, isLoaded, personal } = rest;
|
||||
const {
|
||||
wizardCompleted,
|
||||
isAuthenticated,
|
||||
isLoaded,
|
||||
personal,
|
||||
tenantStatus,
|
||||
} = rest;
|
||||
const renderComponent = (props) => {
|
||||
const isPreparationPortalUrl =
|
||||
props.location.pathname === "/preparation-portal";
|
||||
const isPortalRestoring = tenantStatus === TenantStatus.PortalRestore;
|
||||
|
||||
if (!isLoaded) {
|
||||
return <AppLoader />;
|
||||
}
|
||||
|
||||
if (isAuthenticated || personal) {
|
||||
if (personal) {
|
||||
return (
|
||||
<Redirect
|
||||
to={{
|
||||
@ -22,6 +33,31 @@ export const PublicRoute = ({ component: Component, ...rest }) => {
|
||||
);
|
||||
}
|
||||
|
||||
if (isAuthenticated && !isPortalRestoring) {
|
||||
return (
|
||||
<Redirect
|
||||
to={{
|
||||
pathname: "/",
|
||||
state: { from: props.location },
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (isAuthenticated && isPortalRestoring && !isPreparationPortalUrl) {
|
||||
return (
|
||||
<Redirect
|
||||
to={{
|
||||
pathname: combineUrl(
|
||||
window.DocSpaceConfig?.proxy?.url,
|
||||
"/preparation-portal"
|
||||
),
|
||||
state: { from: props.location },
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (!wizardCompleted && props.location.pathname !== "/wizard") {
|
||||
return (
|
||||
<Redirect
|
||||
@ -33,6 +69,28 @@ export const PublicRoute = ({ component: Component, ...rest }) => {
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
!isAuthenticated &&
|
||||
isPortalRestoring &&
|
||||
wizardCompleted &&
|
||||
!isPreparationPortalUrl
|
||||
) {
|
||||
return (
|
||||
<Redirect
|
||||
to={{
|
||||
pathname: combineUrl(
|
||||
window.DocSpaceConfig?.proxy?.url,
|
||||
"/preparation-portal"
|
||||
),
|
||||
state: { from: props.location },
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (!isAuthenticated && !isPortalRestoring)
|
||||
return window.location.replace("/login");
|
||||
|
||||
return <Component {...props} {...rest} />;
|
||||
};
|
||||
return <Route {...rest} render={renderComponent} />;
|
||||
@ -40,9 +98,10 @@ export const PublicRoute = ({ component: Component, ...rest }) => {
|
||||
|
||||
export default inject(({ auth }) => {
|
||||
const { settingsStore, isAuthenticated, isLoaded } = auth;
|
||||
const { wizardCompleted, personal } = settingsStore;
|
||||
const { wizardCompleted, personal, tenantStatus } = settingsStore;
|
||||
|
||||
return {
|
||||
tenantStatus,
|
||||
wizardCompleted,
|
||||
isAuthenticated,
|
||||
isLoaded,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import React, { useState, useCallback } from "react";
|
||||
import React, { useState, useCallback, useEffect } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import { ButtonsWrapper, LoginFormWrapper } from "./StyledLogin";
|
||||
@ -25,7 +25,7 @@ import { useMounted } from "../helpers/useMounted";
|
||||
import { getBgPattern } from "@docspace/common/utils";
|
||||
import useIsomorphicLayoutEffect from "../hooks/useIsomorphicLayoutEffect";
|
||||
import { useThemeDetector } from "@docspace/common/utils/useThemeDetector";
|
||||
|
||||
import { TenantStatus } from "@docspace/common/constants";
|
||||
interface ILoginProps extends IInitialState {
|
||||
isDesktopEditor?: boolean;
|
||||
}
|
||||
@ -41,13 +41,20 @@ const Login: React.FC<ILoginProps> = ({
|
||||
setTheme,
|
||||
logoUrls,
|
||||
}) => {
|
||||
const isRestoringPortal =
|
||||
portalSettings.tenantStatus === TenantStatus.PortalRestore;
|
||||
|
||||
useEffect(() => {
|
||||
isRestoringPortal && window.location.replace("/preparation-portal");
|
||||
}, []);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [moreAuthVisible, setMoreAuthVisible] = useState(false);
|
||||
const [recoverDialogVisible, setRecoverDialogVisible] = useState(false);
|
||||
|
||||
const { enabledJoin, greetingSettings, enableAdmMess } = portalSettings;
|
||||
const { ssoLabel, ssoUrl } = capabilities;
|
||||
|
||||
const ssoLabel = capabilities?.ssoLabel;
|
||||
const ssoUrl = capabilities?.ssoUrl;
|
||||
const { t } = useTranslation(["Login", "Common"]);
|
||||
const mounted = useMounted();
|
||||
const systemTheme = typeof window !== "undefined" && useThemeDetector();
|
||||
@ -186,6 +193,7 @@ const Login: React.FC<ILoginProps> = ({
|
||||
const logoUrl = !theme.isBase ? logo.path.dark : logo.path.light;
|
||||
|
||||
if (!mounted) return <></>;
|
||||
if (isRestoringPortal) return <></>;
|
||||
|
||||
return (
|
||||
<LoginFormWrapper
|
||||
|
@ -6,9 +6,10 @@ import {
|
||||
getAuthProviders,
|
||||
getCapabilities,
|
||||
getAppearanceTheme,
|
||||
getLogoUrls
|
||||
getLogoUrls,
|
||||
} from "@docspace/common/api/settings";
|
||||
import { checkIsAuthenticated } from "@docspace/common/api/user";
|
||||
import { TenantStatus } from "@docspace/common/constants";
|
||||
|
||||
export const getAssets = (): assetsType => {
|
||||
const manifest = fs.readFileSync(
|
||||
@ -61,23 +62,25 @@ export const getInitialState = async (
|
||||
isAuth: any,
|
||||
logoUrls: any;
|
||||
|
||||
[
|
||||
portalSettings,
|
||||
buildInfo,
|
||||
providers,
|
||||
capabilities,
|
||||
availableThemes,
|
||||
isAuth,
|
||||
logoUrls
|
||||
] = await Promise.all([
|
||||
const baseSettings = [
|
||||
getSettings(),
|
||||
getBuildVersion(),
|
||||
getAppearanceTheme(),
|
||||
getLogoUrls(),
|
||||
];
|
||||
|
||||
const settings = [
|
||||
getAuthProviders(),
|
||||
getCapabilities(),
|
||||
getAppearanceTheme(),
|
||||
checkIsAuthenticated(),
|
||||
getLogoUrls()
|
||||
]);
|
||||
];
|
||||
|
||||
[portalSettings, buildInfo, availableThemes, logoUrls] = await Promise.all(
|
||||
baseSettings
|
||||
);
|
||||
|
||||
if (portalSettings.tenantStatus !== TenantStatus.PortalRestore)
|
||||
[providers, capabilities, isAuth] = await Promise.all(settings);
|
||||
|
||||
const currentColorScheme = availableThemes.themes.find((theme) => {
|
||||
return availableThemes.selected === theme.id;
|
||||
@ -91,7 +94,7 @@ export const getInitialState = async (
|
||||
match: query,
|
||||
currentColorScheme,
|
||||
isAuth,
|
||||
logoUrls
|
||||
logoUrls,
|
||||
};
|
||||
|
||||
return initialState;
|
||||
|
Loading…
Reference in New Issue
Block a user