Fix enable/disable edit mode (#1333)
This commit is contained in:
@@ -90,13 +90,13 @@ function App(
|
||||
});
|
||||
|
||||
const { setInitialPackageAttributes } = usePackageAttributesStore();
|
||||
const { setDisabled } = useEditModeInformationStore();
|
||||
const { setEnabled } = useEditModeInformationStore();
|
||||
|
||||
useEffect(() => {
|
||||
setInitialPackageAttributes(props.pageProps.packageAttributes);
|
||||
|
||||
if (!props.pageProps.editModeEnabled) {
|
||||
setDisabled();
|
||||
if (props.pageProps.editModeEnabled) {
|
||||
setEnabled();
|
||||
}
|
||||
}, []);
|
||||
|
||||
@@ -165,8 +165,7 @@ function App(
|
||||
}
|
||||
|
||||
App.getInitialProps = ({ ctx }: { ctx: GetServerSidePropsContext }) => {
|
||||
const disableEditMode =
|
||||
process.env.DISABLE_EDIT_MODE && process.env.DISABLE_EDIT_MODE.toLowerCase() === 'true';
|
||||
const disableEditMode = process.env.DISABLE_EDIT_MODE?.toLowerCase() === 'true';
|
||||
if (disableEditMode) {
|
||||
Consola.warn(
|
||||
'EXPERIMENTAL: You have disabled the edit mode. Modifications are no longer possible and any requests on the API will be dropped. If you want to disable this, unset the DISABLE_EDIT_MODE environment variable. This behaviour may be removed in future versions of Homarr'
|
||||
|
||||
@@ -8,7 +8,7 @@ import { BackendConfigType, ConfigType } from '../../../types/config';
|
||||
import { IRssWidget } from '../../../widgets/rss/RssWidgetTile';
|
||||
|
||||
function Put(req: NextApiRequest, res: NextApiResponse) {
|
||||
if (process.env.DISABLE_EDIT_MODE === 'true') {
|
||||
if (process.env.DISABLE_EDIT_MODE?.toLowerCase() === 'true') {
|
||||
return res.status(409).json({ error: 'Edit mode has been disabled by the administrator' });
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ function Post(req: NextApiRequest, res: NextApiResponse) {
|
||||
const { tried, type = 'password' } = req.body;
|
||||
// If the type of password is "edit", we run this branch to check the edit password
|
||||
if (type === 'edit') {
|
||||
if ((tried === process.env.EDIT_MODE_PASSWORD) !== undefined) {
|
||||
if (tried === process.env.EDIT_MODE_PASSWORD) {
|
||||
if (process.env.DISABLE_EDIT_MODE?.toLowerCase() === 'true') {
|
||||
process.env.DISABLE_EDIT_MODE = 'false';
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user