mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-17 12:56:05 +00:00
fix: when auth is disabled, the users entity doesn't exist
This commit is contained in:
@@ -4,6 +4,7 @@ import { omit } from "lodash-es";
|
||||
import { type ReactNode, useMemo, useRef, useState } from "react";
|
||||
import { TbSettings } from "react-icons/tb";
|
||||
import { useAuth } from "ui";
|
||||
import { Alert } from "ui/components/display/Alert";
|
||||
import { Link, Route, useLocation } from "wouter";
|
||||
import { useBknd } from "../../../client/BkndProvider";
|
||||
import { Button } from "../../../components/buttons/Button";
|
||||
@@ -36,6 +37,7 @@ export type SettingProps<
|
||||
allowDelete?: (config: any) => boolean;
|
||||
allowEdit?: (config: any) => boolean;
|
||||
showAlert?: (config: any) => string | ReactNode | undefined;
|
||||
reloadOnSave?: boolean;
|
||||
};
|
||||
properties?: {
|
||||
[key in keyof Partial<Props>]: {
|
||||
@@ -151,6 +153,9 @@ export function Setting<Schema extends TObject = any>({
|
||||
|
||||
console.log("save:success", success);
|
||||
if (success) {
|
||||
if (options?.reloadOnSave) {
|
||||
window.location.reload();
|
||||
}
|
||||
//window.location.reload();
|
||||
} else {
|
||||
setSubmitting(false);
|
||||
@@ -229,11 +234,7 @@ export function Setting<Schema extends TObject = any>({
|
||||
<Breadcrumbs path={path} />
|
||||
</AppShell.SectionHeader>
|
||||
<AppShell.Scrollable key={path.join("-")}>
|
||||
{showAlert && (
|
||||
<div className="flex flex-row dark:bg-amber-300/20 bg-amber-200 p-4">
|
||||
{showAlert}
|
||||
</div>
|
||||
)}
|
||||
{typeof showAlert === "string" && <Alert.Warning message={showAlert} />}
|
||||
|
||||
<div className="flex flex-col flex-grow p-3 gap-3">
|
||||
<JsonSchemaForm
|
||||
|
||||
@@ -70,9 +70,11 @@ export const SettingNewModal = ({
|
||||
const [module, ...restOfPath] = path;
|
||||
const addPath = [...restOfPath, newKey].join(".");
|
||||
if (await actions.add(module as any, addPath, data)) {
|
||||
navigate(prefixPath + newKey, {
|
||||
replace: true
|
||||
});
|
||||
setTimeout(() => {
|
||||
navigate(prefixPath + newKey, {
|
||||
replace: true
|
||||
});
|
||||
}, 500);
|
||||
} else {
|
||||
setSubmitting(false);
|
||||
}
|
||||
|
||||
@@ -115,6 +115,15 @@ export const AuthSettings = ({ schema: _unsafe_copy, config }) => {
|
||||
schema={_schema}
|
||||
uiSchema={uiSchema}
|
||||
config={config}
|
||||
options={{
|
||||
showAlert: (config: any) => {
|
||||
if (!config.enabled) {
|
||||
return "Auth is disabled. Enable it by toggling the switch below. Please also make sure set a secure secret to sign JWT tokens.";
|
||||
}
|
||||
return;
|
||||
},
|
||||
reloadOnSave: true
|
||||
}}
|
||||
properties={{
|
||||
strategies: {
|
||||
extract: true,
|
||||
|
||||
Reference in New Issue
Block a user