mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-09 05:20:13 +02:00
render login page on SERVER_LOCK (#1172)
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import isElectron from 'is-electron';
|
||||
import { useMemo } from 'react';
|
||||
import { Navigate, Outlet } from 'react-router';
|
||||
|
||||
@@ -9,14 +8,10 @@ import { Center } from '/@/shared/components/center/center';
|
||||
import { Spinner } from '/@/shared/components/spinner/spinner';
|
||||
import { AuthState } from '/@/shared/types/types';
|
||||
|
||||
const localSettings = isElectron() ? window.api.localSettings : null;
|
||||
|
||||
export const AppOutlet = () => {
|
||||
const currentServer = useCurrentServer();
|
||||
const authState = useServerAuthenticated();
|
||||
|
||||
const serverLock = localSettings?.env.SERVER_LOCK || false;
|
||||
|
||||
const isActionsRequired = useMemo(() => {
|
||||
const isServerRequired = !currentServer;
|
||||
|
||||
@@ -34,12 +29,7 @@ export const AppOutlet = () => {
|
||||
);
|
||||
}
|
||||
|
||||
// When server lock is enabled always redirect to login
|
||||
if (serverLock && !currentServer) {
|
||||
return <Navigate replace to={AppRoute.LOGIN} />;
|
||||
}
|
||||
|
||||
if (!serverLock && (isActionsRequired || authState === AuthState.INVALID)) {
|
||||
if (isActionsRequired || authState === AuthState.INVALID) {
|
||||
return <Navigate replace to={AppRoute.ACTION_REQUIRED} />;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user