mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
Fix Release 0.11.1 (#150)
* fix strategy forms handling, add register route and hidden fields Refactored strategy forms to include hidden fields for type and name. Added a registration route with necessary adjustments to the admin controller and routes. Corrected field handling within relevant forms and components. * fix admin access permissions and refactor routing structure display a fixed error for unmet permissions when retrieving the schema. moved auth routes outside of BkndProvider and reorganized remaining routes to include BkndWrapper. * fix: properly type BkndWrapper * bump fix release version * ModuleManager: update diff checking and AppData validation Revised diff handling includes validation of diffs, reverting changes on failure, and enforcing module constraints with onBeforeUpdate hooks. Introduced `validateDiffs` and backup of stable configs. Applied changes in related modules, tests, and UI layer to align with updated diff logic. * fix: cli: running from config file were using invalid args * fix: cli: improve sequence of onBuilt trigger to allow custom routes from cli * fix e2e tests
This commit is contained in:
18
app/src/ui/routes/auth/auth.register.tsx
Normal file
18
app/src/ui/routes/auth/auth.register.tsx
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Logo } from "ui/components/display/Logo";
|
||||
import { Link } from "ui/components/wouter/Link";
|
||||
import { Auth } from "ui/elements";
|
||||
import { useBrowserTitle } from "ui/hooks/use-browser-title";
|
||||
|
||||
export function AuthRegister() {
|
||||
useBrowserTitle(["Register"]);
|
||||
return (
|
||||
<Auth.Screen
|
||||
action="register"
|
||||
logo={
|
||||
<Link href={"/"} className="link">
|
||||
<Logo scale={0.25} />
|
||||
</Link>
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import {
|
||||
Form,
|
||||
FormContextOverride,
|
||||
FormDebug,
|
||||
HiddenField,
|
||||
ObjectField,
|
||||
Subscribe,
|
||||
useDerivedFieldContext,
|
||||
@@ -36,9 +37,16 @@ import * as AppShell from "../../layouts/AppShell/AppShell";
|
||||
export function AuthStrategiesList(props) {
|
||||
useBrowserTitle(["Auth", "Strategies"]);
|
||||
|
||||
const { hasSecrets } = useBknd({ withSecrets: true });
|
||||
const {
|
||||
hasSecrets,
|
||||
config: {
|
||||
auth: { enabled },
|
||||
},
|
||||
} = useBknd({ withSecrets: true });
|
||||
if (!hasSecrets) {
|
||||
return <Message.MissingPermission what="Auth Strategies" />;
|
||||
} else if (!enabled) {
|
||||
return <Message.NotEnabled description="Enable Auth first." />;
|
||||
}
|
||||
|
||||
return <AuthStrategiesListInternal {...props} />;
|
||||
@@ -62,7 +70,6 @@ function AuthStrategiesListInternal() {
|
||||
);
|
||||
|
||||
async function handleSubmit(data: any) {
|
||||
console.log("submit", { strategies: data });
|
||||
await $auth.actions.config.set({ strategies: data });
|
||||
}
|
||||
|
||||
@@ -152,7 +159,7 @@ const Strategy = ({ type, name, unavailable }: StrategyProps) => {
|
||||
<span className="leading-none">{autoFormatString(name)}</span>
|
||||
</div>
|
||||
<div className="flex flex-row gap-4 items-center">
|
||||
<StrategyToggle />
|
||||
<StrategyToggle type={type} />
|
||||
<IconButton
|
||||
Icon={TbSettings}
|
||||
size="lg"
|
||||
@@ -168,7 +175,7 @@ const Strategy = ({ type, name, unavailable }: StrategyProps) => {
|
||||
"flex flex-col border-t border-t-muted px-4 pt-3 pb-4 bg-lightest/50 gap-4",
|
||||
)}
|
||||
>
|
||||
<StrategyForm type={type} />
|
||||
<StrategyForm type={type} name={name} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@@ -176,7 +183,7 @@ const Strategy = ({ type, name, unavailable }: StrategyProps) => {
|
||||
);
|
||||
};
|
||||
|
||||
const StrategyToggle = () => {
|
||||
const StrategyToggle = ({ type }: { type: StrategyProps["type"] }) => {
|
||||
const ctx = useDerivedFieldContext("");
|
||||
const { value } = useFormValue("");
|
||||
|
||||
@@ -219,8 +226,10 @@ const OAUTH_BRANDS = {
|
||||
discord: TbBrandDiscordFilled,
|
||||
};
|
||||
|
||||
const StrategyForm = ({ type }: Pick<StrategyProps, "type">) => {
|
||||
let Component = () => <ObjectField path="" wrapperProps={{ wrapper: "group", label: false }} />;
|
||||
const StrategyForm = ({ type, name }: Pick<StrategyProps, "type" | "name">) => {
|
||||
let Component = (p: any) => (
|
||||
<ObjectField path="" wrapperProps={{ wrapper: "group", label: false }} />
|
||||
);
|
||||
switch (type) {
|
||||
case "password":
|
||||
Component = StrategyPasswordForm;
|
||||
@@ -230,16 +239,22 @@ const StrategyForm = ({ type }: Pick<StrategyProps, "type">) => {
|
||||
break;
|
||||
}
|
||||
|
||||
return <Component />;
|
||||
return (
|
||||
<>
|
||||
<HiddenField name="type" inputProps={{ disabled: true, defaultValue: type }} />
|
||||
<Component type={type} name={name} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const StrategyPasswordForm = () => {
|
||||
return <ObjectField path="config" wrapperProps={{ wrapper: "group", label: false }} />;
|
||||
};
|
||||
|
||||
const StrategyOAuthForm = () => {
|
||||
const StrategyOAuthForm = ({ type, name }: Pick<StrategyProps, "type" | "name">) => {
|
||||
return (
|
||||
<>
|
||||
<HiddenField name="config.name" inputProps={{ disabled: true, defaultValue: name }} />
|
||||
<Field name="config.client.client_id" required inputProps={{ type: "password" }} />
|
||||
<Field name="config.client.client_secret" required inputProps={{ type: "password" }} />
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user