mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Moved env checks to server pages.
This commit is contained in:
parent
5b6292dd11
commit
784677e180
7 changed files with 18 additions and 18 deletions
|
|
@ -22,10 +22,6 @@ export function App({ children }) {
|
|||
return null;
|
||||
}
|
||||
|
||||
if (config.uiDisabled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{children}
|
||||
|
|
|
|||
|
|
@ -2,22 +2,18 @@
|
|||
|
||||
export type Config = {
|
||||
faviconUrl: string | undefined;
|
||||
loginDisabled: boolean;
|
||||
privateMode: boolean;
|
||||
telemetryDisabled: boolean;
|
||||
trackerScriptName: string | undefined;
|
||||
uiDisabled: boolean;
|
||||
updatesDisabled: boolean;
|
||||
};
|
||||
|
||||
export async function getConfig(): Promise<Config> {
|
||||
return {
|
||||
faviconUrl: process.env.FAVICON_URL,
|
||||
loginDisabled: !!process.env.DISABLE_LOGIN,
|
||||
privateMode: !!process.env.PRIVATE_MODE,
|
||||
telemetryDisabled: !!process.env.DISABLE_TELEMETRY,
|
||||
trackerScriptName: process.env.TRACKER_SCRIPT_NAME,
|
||||
uiDisabled: !!process.env.DISABLE_UI,
|
||||
updatesDisabled: !!process.env.DISABLE_UPDATES,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,14 @@ import '@/styles/index.css';
|
|||
import '@/styles/variables.css';
|
||||
|
||||
export default function ({ children }) {
|
||||
if (process.env.DISABLE_UI) {
|
||||
return (
|
||||
<html>
|
||||
<body></body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<html lang="en" data-scroll="0">
|
||||
<head>
|
||||
|
|
|
|||
|
|
@ -1,15 +1,8 @@
|
|||
'use client';
|
||||
import { useConfig } from '@/components/hooks';
|
||||
import LoginForm from './LoginForm';
|
||||
import styles from './LoginPage.module.css';
|
||||
|
||||
export function LoginPage() {
|
||||
const config = useConfig();
|
||||
|
||||
if (config?.loginDisabled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={styles.page}>
|
||||
<LoginForm />
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@ import { Metadata } from 'next';
|
|||
import LoginPage from './LoginPage';
|
||||
|
||||
export default async function () {
|
||||
if (process.env.DISABLE_LOGIN) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <LoginPage />;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,14 @@
|
|||
'use client';
|
||||
import { useEffect } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useApi, useConfig } from '@/components/hooks';
|
||||
import { useApi } from '@/components/hooks';
|
||||
import { setUser } from '@/store/app';
|
||||
import { removeClientAuthToken } from '@/lib/client';
|
||||
|
||||
export function LogoutPage() {
|
||||
const config = useConfig();
|
||||
const router = useRouter();
|
||||
const { post } = useApi();
|
||||
const disabled = !!(config?.loginDisabled || process.env.cloudMode);
|
||||
const disabled = process.env.cloudMode;
|
||||
|
||||
useEffect(() => {
|
||||
async function logout() {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@ import LogoutPage from './LogoutPage';
|
|||
import { Metadata } from 'next';
|
||||
|
||||
export default function () {
|
||||
if (process.env.DISABLE_LOGIN) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <LogoutPage />;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue