Login: add sample for confirm pages

This commit is contained in:
Timofey Boyko 2024-06-20 15:16:45 +03:00
parent 152c124140
commit 6023a92ea0
5 changed files with 77 additions and 14 deletions

View File

@ -0,0 +1,35 @@
// (c) Copyright Ascensio System SIA 2009-2024
//
// This program is a free software product.
// You can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
// any third-party rights.
//
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//
// The interactive user interfaces in modified source and object code versions of the Program must
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
//
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
// trademark law for use of our trademarks.
//
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
type EmailActivationProps = {
searchParams: { [key: string]: string };
};
async function Page({ searchParams }: EmailActivationProps) {
return <div>Email activation</div>;
}
export default Page;

View File

@ -0,0 +1,33 @@
// (c) Copyright Ascensio System SIA 2009-2024
//
// This program is a free software product.
// You can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
// any third-party rights.
//
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//
// The interactive user interfaces in modified source and object code versions of the Program must
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
//
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
// trademark law for use of our trademarks.
//
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
export default async function Layout({
children,
}: {
children: React.ReactNode;
}) {
return children;
}

View File

@ -51,18 +51,11 @@ export default async function RootLayout({
let redirectUrl = ""; let redirectUrl = "";
const timers = { otherOperations: 0 };
const startOtherOperationsDate = new Date();
const [settings, colorTheme] = await Promise.all([ const [settings, colorTheme] = await Promise.all([
getSettings(), getSettings(),
getColorTheme(), getColorTheme(),
]); ]);
timers.otherOperations =
new Date().getTime() - startOtherOperationsDate.getTime();
if (settings === "access-restricted") redirectUrl = `/${settings}`; if (settings === "access-restricted") redirectUrl = `/${settings}`;
if (settings === "portal-not-found") { if (settings === "portal-not-found") {
@ -125,7 +118,6 @@ export default async function RootLayout({
systemTheme: systemTheme?.value as ThemeKeys, systemTheme: systemTheme?.value as ThemeKeys,
}} }}
redirectURL={redirectUrl} redirectURL={redirectUrl}
timers={timers}
> >
<Toast isSSR /> <Toast isSSR />
{children} {children}

View File

@ -39,6 +39,13 @@ export function middleware(request: NextRequest) {
return NextResponse.json({ status: "healthy" }, { status: 200 }); return NextResponse.json({ status: "healthy" }, { status: 200 });
} }
console.log(request.nextUrl.pathname);
if (request.nextUrl.pathname.includes("confirm")) {
console.log("call" );
return NextResponse.rewrite(`/login/${request.nextUrl.pathname}`);
}
const isAuth = !!request.cookies.get("asc_auth_key")?.value; const isAuth = !!request.cookies.get("asc_auth_key")?.value;
const url = request.nextUrl.clone(); const url = request.nextUrl.clone();
@ -49,5 +56,5 @@ export function middleware(request: NextRequest) {
// See "Matching Paths" below to learn more // See "Matching Paths" below to learn more
export const config = { export const config = {
matcher: ["/health", "/", "/not-found"], matcher: ["/health", "/", "/not-found", "/confirm"],
}; };

View File

@ -46,7 +46,7 @@ import ErrorBoundaryWrapper from "./ErrorBoundary";
export const Providers = ({ export const Providers = ({
children, children,
value, value,
timers,
redirectURL, redirectURL,
}: { }: {
children: React.ReactNode; children: React.ReactNode;
@ -61,10 +61,6 @@ export const Providers = ({
if (redirectURL) window.location.replace(redirectURL); if (redirectURL) window.location.replace(redirectURL);
}, [redirectURL]); }, [redirectURL]);
React.useEffect(() => {
console.log("Timers:", { ...timers });
}, [timers]);
const { i18n } = useI18N({ const { i18n } = useI18N({
settings: value.settings, settings: value.settings,
}); });