2025-02-09 18:05:31 +01:00
|
|
|
import { TranslationKeys, useLocalize } from '~/hooks';
|
2024-05-28 05:25:07 -07:00
|
|
|
import { TStartupConfig } from 'librechat-data-provider';
|
2025-06-02 13:49:10 +02:00
|
|
|
import { ErrorMessage } from '~/components/Auth/ErrorMessage';
|
2024-05-28 05:25:07 -07:00
|
|
|
import SocialLoginRender from './SocialLoginRender';
|
2025-06-02 13:49:10 +02:00
|
|
|
import { BlinkAnimation } from './BlinkAnimation';
|
|
|
|
|
import { ThemeSelector } from '~/components';
|
2024-09-11 06:34:25 -07:00
|
|
|
import { Banner } from '../Banners';
|
2024-05-28 05:25:07 -07:00
|
|
|
import Footer from './Footer';
|
|
|
|
|
|
|
|
|
|
function AuthLayout({
|
|
|
|
|
children,
|
|
|
|
|
header,
|
|
|
|
|
isFetching,
|
|
|
|
|
startupConfig,
|
|
|
|
|
startupConfigError,
|
|
|
|
|
pathname,
|
|
|
|
|
error,
|
|
|
|
|
}: {
|
|
|
|
|
children: React.ReactNode;
|
|
|
|
|
header: React.ReactNode;
|
|
|
|
|
isFetching: boolean;
|
|
|
|
|
startupConfig: TStartupConfig | null | undefined;
|
|
|
|
|
startupConfigError: unknown | null | undefined;
|
|
|
|
|
pathname: string;
|
2025-02-09 18:05:31 +01:00
|
|
|
error: TranslationKeys | null;
|
2024-05-28 05:25:07 -07:00
|
|
|
}) {
|
|
|
|
|
const localize = useLocalize();
|
|
|
|
|
|
2024-12-13 15:44:22 -05:00
|
|
|
const hasStartupConfigError = startupConfigError !== null && startupConfigError !== undefined;
|
2024-05-28 05:25:07 -07:00
|
|
|
const DisplayError = () => {
|
2024-12-13 15:44:22 -05:00
|
|
|
if (hasStartupConfigError) {
|
2025-06-02 13:49:10 +02:00
|
|
|
return (
|
|
|
|
|
<div className="mx-auto sm:max-w-sm">
|
|
|
|
|
<ErrorMessage>{localize('com_auth_error_login_server')}</ErrorMessage>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2024-05-28 05:25:07 -07:00
|
|
|
} else if (error === 'com_auth_error_invalid_reset_token') {
|
|
|
|
|
return (
|
2025-06-02 13:49:10 +02:00
|
|
|
<div className="mx-auto sm:max-w-sm">
|
|
|
|
|
<ErrorMessage>
|
|
|
|
|
{localize('com_auth_error_invalid_reset_token')}{' '}
|
|
|
|
|
<a className="font-semibold text-green-600 hover:underline" href="/forgot-password">
|
|
|
|
|
{localize('com_auth_click_here')}
|
|
|
|
|
</a>{' '}
|
|
|
|
|
{localize('com_auth_to_try_again')}
|
|
|
|
|
</ErrorMessage>
|
|
|
|
|
</div>
|
2024-05-28 05:25:07 -07:00
|
|
|
);
|
2024-12-13 15:44:22 -05:00
|
|
|
} else if (error != null && error) {
|
2025-06-02 13:49:10 +02:00
|
|
|
return (
|
|
|
|
|
<div className="mx-auto sm:max-w-sm">
|
|
|
|
|
<ErrorMessage>{localize(error)}</ErrorMessage>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2024-05-28 05:25:07 -07:00
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="relative flex min-h-screen flex-col bg-white dark:bg-gray-900">
|
2024-09-11 06:34:25 -07:00
|
|
|
<Banner />
|
2024-05-28 05:25:07 -07:00
|
|
|
<BlinkAnimation active={isFetching}>
|
2024-09-11 04:20:19 -09:00
|
|
|
<div className="mt-6 h-10 w-full bg-cover">
|
2024-12-13 15:44:22 -05:00
|
|
|
<img
|
|
|
|
|
src="/assets/logo.svg"
|
|
|
|
|
className="h-full w-full object-contain"
|
2025-02-09 18:05:31 +01:00
|
|
|
alt={localize('com_ui_logo', { 0: startupConfig?.appTitle ?? 'LibreChat' })}
|
2024-12-13 15:44:22 -05:00
|
|
|
/>
|
2024-05-28 05:25:07 -07:00
|
|
|
</div>
|
|
|
|
|
</BlinkAnimation>
|
|
|
|
|
<DisplayError />
|
|
|
|
|
<div className="absolute bottom-0 left-0 md:m-4">
|
|
|
|
|
<ThemeSelector />
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="flex flex-grow items-center justify-center">
|
|
|
|
|
<div className="w-authPageWidth overflow-hidden bg-white px-6 py-4 dark:bg-gray-900 sm:max-w-md sm:rounded-lg">
|
2024-12-13 15:44:22 -05:00
|
|
|
{!hasStartupConfigError && !isFetching && (
|
2024-05-28 05:25:07 -07:00
|
|
|
<h1
|
|
|
|
|
className="mb-4 text-center text-3xl font-semibold text-black dark:text-white"
|
|
|
|
|
style={{ userSelect: 'none' }}
|
|
|
|
|
>
|
|
|
|
|
{header}
|
|
|
|
|
</h1>
|
|
|
|
|
)}
|
|
|
|
|
{children}
|
2025-02-18 01:09:36 +01:00
|
|
|
{!pathname.includes('2fa') &&
|
|
|
|
|
(pathname.includes('login') || pathname.includes('register')) && (
|
2025-06-02 13:49:10 +02:00
|
|
|
<SocialLoginRender startupConfig={startupConfig} />
|
|
|
|
|
)}
|
2024-05-28 05:25:07 -07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<Footer startupConfig={startupConfig} />
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default AuthLayout;
|