mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-06 20:10:12 +02:00
fix: properly handle server lock and related properties
This commit is contained in:
+3
-1
@@ -20,6 +20,8 @@ COPY --chown=nginx:nginx --from=builder /app/out/web /usr/share/nginx/html
|
||||
COPY ./settings.js.template /etc/nginx/templates/settings.js.template
|
||||
COPY ng.conf.template /etc/nginx/templates/default.conf.template
|
||||
|
||||
ENV PUBLIC_PATH="/"
|
||||
ENV SERVER_LOCK=false SERVER_NAME="" SERVER_TYPE="" SERVER_URL=""
|
||||
ENV LEGACY_AUTHENTICATION="" ANALYTICS_DISABLED="" PUBLIC_PATH="/"
|
||||
|
||||
EXPOSE 9180
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
||||
+2
-2
@@ -5,9 +5,9 @@ services:
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- SERVER_NAME=jellyfin # pre-defined server name
|
||||
- SERVER_LOCK=true # When true AND name/type/url are set, only username/password can be toggled
|
||||
- SERVER_LOCK=false # When true AND name/type/url are set, only username/password can be toggled
|
||||
- SERVER_TYPE=jellyfin # the allowed types are: jellyfin, navidrome, subsonic. These values are case insensitive
|
||||
- SERVER_URL= # http://address:port or https://address:port
|
||||
- SERVER_URL=http://localhost:8096 # http://address:port or https://address:port
|
||||
- LEGACY_AUTHENTICATION=false # When SERVER_LOCK is true, sets the legacyauth flag for server authentication (true or false)
|
||||
- ANALYTICS_DISABLED=false # Set to true to disable Umami analytics tracking
|
||||
ports:
|
||||
|
||||
@@ -1 +1 @@
|
||||
"use strict";window.SERVER_URL="${SERVER_URL}";window.SERVER_NAME="${SERVER_NAME}";window.SERVER_TYPE="${SERVER_TYPE}";window.SERVER_LOCK=${SERVER_LOCK};window.LEGACY_AUTHENTICATION=${LEGACY_AUTHENTICATION};window.ANALYTICS_DISABLED="${ANALYTICS_DISABLED}";
|
||||
"use strict";window.SERVER_URL="${SERVER_URL}";window.SERVER_NAME="${SERVER_NAME}";window.SERVER_TYPE="${SERVER_TYPE}";window.SERVER_LOCK="${SERVER_LOCK}";window.LEGACY_AUTHENTICATION="${LEGACY_AUTHENTICATION}";window.ANALYTICS_DISABLED="${ANALYTICS_DISABLED}";
|
||||
|
||||
@@ -3,6 +3,7 @@ import isElectron from 'is-electron';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useNavigate } from 'react-router';
|
||||
|
||||
import { isServerLock } from '/@/renderer/features/action-required/utils/window-properties';
|
||||
import JellyfinLogo from '/@/renderer/features/servers/assets/jellyfin.png';
|
||||
import NavidromeLogo from '/@/renderer/features/servers/assets/navidrome.png';
|
||||
import OpenSubsonicLogo from '/@/renderer/features/servers/assets/opensubsonic.png';
|
||||
@@ -28,14 +29,12 @@ const localSettings = isElectron() ? window.api.localSettings : null;
|
||||
export const ServerRequired = () => {
|
||||
const serverList = useServerList();
|
||||
|
||||
const isServerLock = Boolean(window.SERVER_LOCK) || false;
|
||||
|
||||
if (Object.keys(serverList).length > 0) {
|
||||
return (
|
||||
<ScrollArea>
|
||||
<Stack miw="300px">
|
||||
<ServerSelector />
|
||||
{!isServerLock && (
|
||||
{!isServerLock() && (
|
||||
<>
|
||||
<Divider my="lg" />
|
||||
<AddServerForm onCancel={null} />
|
||||
|
||||
@@ -6,6 +6,7 @@ import { PageHeader } from '/@/renderer/components/page-header/page-header';
|
||||
import { ActionRequiredContainer } from '/@/renderer/features/action-required/components/action-required-container';
|
||||
import { ServerCredentialRequired } from '/@/renderer/features/action-required/components/server-credential-required';
|
||||
import { ServerRequired } from '/@/renderer/features/action-required/components/server-required';
|
||||
import { isServerLock } from '/@/renderer/features/action-required/utils/window-properties';
|
||||
import LoginRoute from '/@/renderer/features/login/routes/login-route';
|
||||
import { ServerList } from '/@/renderer/features/servers/components/server-list';
|
||||
import { AnimatedPage } from '/@/renderer/features/shared/components/animated-page';
|
||||
@@ -25,8 +26,7 @@ const ActionRequiredRoute = () => {
|
||||
const isServerRequired = !currentServer;
|
||||
const isCredentialRequired = currentServer && !currentServer.credential;
|
||||
|
||||
const isServerLock = Boolean(window.SERVER_LOCK) || false;
|
||||
const isLoginRequired = isServerLock && !currentServer;
|
||||
const isLoginRequired = isServerLock() && !currentServer;
|
||||
|
||||
const checks = [
|
||||
{
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
export const isLegacyAuth = () =>
|
||||
window.LEGACY_AUTHENTICATION === true || window.LEGACY_AUTHENTICATION === 'true';
|
||||
|
||||
export const isServerLock = () => window.SERVER_LOCK === true || window.SERVER_LOCK === 'true';
|
||||
@@ -6,6 +6,10 @@ import { Navigate } from 'react-router';
|
||||
|
||||
import { api } from '/@/renderer/api';
|
||||
import { PageHeader } from '/@/renderer/components/page-header/page-header';
|
||||
import {
|
||||
isLegacyAuth,
|
||||
isServerLock,
|
||||
} from '/@/renderer/features/action-required/utils/window-properties';
|
||||
import JellyfinIcon from '/@/renderer/features/servers/assets/jellyfin.png';
|
||||
import NavidromeIcon from '/@/renderer/features/servers/assets/navidrome.png';
|
||||
import SubsonicIcon from '/@/renderer/features/servers/assets/opensubsonic.png';
|
||||
@@ -48,17 +52,17 @@ const LoginRoute = () => {
|
||||
const currentServer = useCurrentServer();
|
||||
|
||||
// Check if server lock is configured
|
||||
const isServerLock = Boolean(window.SERVER_LOCK) || false;
|
||||
const serverLock = isServerLock();
|
||||
const serverType = window.SERVER_TYPE ? toServerType(window.SERVER_TYPE) : null;
|
||||
const serverName = window.SERVER_NAME || '';
|
||||
const serverUrl = window.SERVER_URL || '';
|
||||
const legacyAuth = isServerLock ? Boolean(window.LEGACY_AUTHENTICATION) || false : false;
|
||||
const legacyAuth = serverLock && isLegacyAuth();
|
||||
|
||||
const config = [
|
||||
{
|
||||
isValid: true,
|
||||
key: 'SERVER_LOCK',
|
||||
value: isServerLock,
|
||||
value: serverLock,
|
||||
},
|
||||
{
|
||||
isValid: serverType !== null,
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Dispatch, useCallback } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useNavigate } from 'react-router';
|
||||
|
||||
import { isServerLock } from '/@/renderer/features/action-required/utils/window-properties';
|
||||
import { Command, CommandPalettePages } from '/@/renderer/features/search/components/command';
|
||||
import { ServerList } from '/@/renderer/features/servers/components/server-list';
|
||||
import { AppRoute } from '/@/renderer/router/routes';
|
||||
@@ -42,8 +43,6 @@ export const ServerCommands = ({ handleClose, setPages, setQuery }: ServerComman
|
||||
[handleClose, navigate, setCurrentServer, setPages, setQuery],
|
||||
);
|
||||
|
||||
const isServerLock = Boolean(window.SERVER_LOCK) || false;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Command.Group
|
||||
@@ -56,7 +55,7 @@ export const ServerCommands = ({ handleClose, setPages, setQuery }: ServerComman
|
||||
>{`${serverList[key].name}...`}</Command.Item>
|
||||
))}
|
||||
</Command.Group>
|
||||
{!isServerLock && (
|
||||
{!isServerLock() && (
|
||||
<Command.Group heading={t('common.manage', { postProcess: 'sentenceCase' })}>
|
||||
<Command.Item onSelect={handleManageServersModal}>
|
||||
{t('page.appMenu.manageServers', { postProcess: 'sentenceCase' })}...
|
||||
|
||||
@@ -5,6 +5,10 @@ import { useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { api } from '/@/renderer/api';
|
||||
import {
|
||||
isLegacyAuth,
|
||||
isServerLock,
|
||||
} from '/@/renderer/features/action-required/utils/window-properties';
|
||||
import JellyfinIcon from '/@/renderer/features/servers/assets/jellyfin.png';
|
||||
import NavidromeIcon from '/@/renderer/features/servers/assets/navidrome.png';
|
||||
import SubsonicIcon from '/@/renderer/features/servers/assets/opensubsonic.png';
|
||||
@@ -94,8 +98,8 @@ export const AddServerForm = ({ onCancel }: AddServerFormProps) => {
|
||||
const { addServer, setCurrentServer } = useAuthStoreActions();
|
||||
const { servers: discovered } = useAutodiscovery();
|
||||
|
||||
const isServerLock = Boolean(window.SERVER_LOCK) || false;
|
||||
const legacyAuthDefault = isServerLock ? Boolean(window.LEGACY_AUTHENTICATION) || false : false;
|
||||
const serverLock = isServerLock();
|
||||
const legacyAuthDefault = serverLock && isLegacyAuth();
|
||||
|
||||
const form = useForm({
|
||||
initialValues: {
|
||||
@@ -231,7 +235,7 @@ export const AddServerForm = ({ onCancel }: AddServerFormProps) => {
|
||||
<Stack m={5} ref={focusTrapRef}>
|
||||
<SegmentedControl
|
||||
data={ALL_SERVERS}
|
||||
disabled={isServerLock}
|
||||
disabled={serverLock}
|
||||
p="md"
|
||||
withItemsBorders={false}
|
||||
{...form.getInputProps('type')}
|
||||
@@ -239,7 +243,7 @@ export const AddServerForm = ({ onCancel }: AddServerFormProps) => {
|
||||
<Group grow>
|
||||
<TextInput
|
||||
data-autofocus
|
||||
disabled={isServerLock}
|
||||
disabled={serverLock}
|
||||
label={t('form.addServer.input', {
|
||||
context: 'name',
|
||||
postProcess: 'titleCase',
|
||||
@@ -248,7 +252,7 @@ export const AddServerForm = ({ onCancel }: AddServerFormProps) => {
|
||||
{...form.getInputProps('name')}
|
||||
/>
|
||||
<TextInput
|
||||
disabled={isServerLock}
|
||||
disabled={serverLock}
|
||||
label={t('form.addServer.input', {
|
||||
context: 'url',
|
||||
postProcess: 'titleCase',
|
||||
@@ -258,7 +262,7 @@ export const AddServerForm = ({ onCancel }: AddServerFormProps) => {
|
||||
/>
|
||||
</Group>
|
||||
<TextInput
|
||||
disabled={isServerLock}
|
||||
disabled={serverLock}
|
||||
label={t('form.addServer.input', {
|
||||
context: 'remoteUrl',
|
||||
postProcess: 'titleCase',
|
||||
@@ -308,7 +312,7 @@ export const AddServerForm = ({ onCancel }: AddServerFormProps) => {
|
||||
)}
|
||||
{form.values.type === ServerType.SUBSONIC && (
|
||||
<Checkbox
|
||||
disabled={isServerLock}
|
||||
disabled={serverLock}
|
||||
label={t('form.addServer.input', {
|
||||
context: 'legacyAuthentication',
|
||||
postProcess: 'titleCase',
|
||||
|
||||
@@ -3,6 +3,7 @@ import { useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useNavigate } from 'react-router';
|
||||
|
||||
import { isServerLock } from '/@/renderer/features/action-required/utils/window-properties';
|
||||
import JellyfinLogo from '/@/renderer/features/servers/assets/jellyfin.png';
|
||||
import NavidromeLogo from '/@/renderer/features/servers/assets/navidrome.png';
|
||||
import OpenSubsonicLogo from '/@/renderer/features/servers/assets/opensubsonic.png';
|
||||
@@ -88,8 +89,6 @@ export const ServerSelectorItems = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const isServerLock = Boolean(window.SERVER_LOCK) || false;
|
||||
|
||||
return (
|
||||
<>
|
||||
<DropdownMenu.Label>
|
||||
@@ -123,7 +122,7 @@ export const ServerSelectorItems = () => {
|
||||
</DropdownMenu.Item>
|
||||
);
|
||||
})}
|
||||
{!isServerLock && (
|
||||
{!isServerLock() && (
|
||||
<DropdownMenu.Item
|
||||
leftSection={<Icon icon="edit" />}
|
||||
onClick={handleManageServersModal}
|
||||
|
||||
@@ -6,6 +6,7 @@ import { Link, useNavigate } from 'react-router';
|
||||
|
||||
import packageJson from '../../../../../package.json';
|
||||
|
||||
import { isServerLock } from '/@/renderer/features/action-required/utils/window-properties';
|
||||
import { ServerList } from '/@/renderer/features/servers/components/server-list';
|
||||
import { openSettingsModal } from '/@/renderer/features/settings/utils/open-settings-modal';
|
||||
import { useAppStore, useAppStoreActions, useCommandPalette } from '/@/renderer/store';
|
||||
@@ -175,7 +176,7 @@ export const AppMenu = () => {
|
||||
type: 'divider',
|
||||
},
|
||||
{
|
||||
condition: !window.SERVER_LOCK,
|
||||
condition: !isServerLock(),
|
||||
id: 'manage-servers',
|
||||
item: {
|
||||
label: t('page.appMenu.manageServers', { postProcess: 'sentenceCase' }),
|
||||
|
||||
Vendored
+2
-2
@@ -1,8 +1,8 @@
|
||||
declare global {
|
||||
interface Window {
|
||||
ANALYTICS_DISABLED?: boolean | string;
|
||||
LEGACY_AUTHENTICATION?: boolean;
|
||||
SERVER_LOCK?: boolean;
|
||||
LEGACY_AUTHENTICATION?: boolean | string;
|
||||
SERVER_LOCK?: boolean | string;
|
||||
SERVER_NAME?: string;
|
||||
SERVER_TYPE?: string;
|
||||
SERVER_URL?: string;
|
||||
|
||||
Reference in New Issue
Block a user