feat(security): isolate bounded work and support required auth actions
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
import { FormLayout } from "../../components/ContentGrid";
|
||||
import { useId, useState } from "react";
|
||||
import type { ApiSettings, LoginResponse } from "../../types";
|
||||
import type { ApiSettings, AuthActionUiCapability, LoginResponse } from "../../types";
|
||||
import { login } from "../../api/auth";
|
||||
import Button from "../../components/Button";
|
||||
import Dialog from "../../components/Dialog";
|
||||
import FormField from "../../components/FormField";
|
||||
import PasswordField from "../../components/PasswordField";
|
||||
import DismissibleAlert from "../../components/DismissibleAlert";
|
||||
import { usePlatformUiCapability } from "../../platform/ModuleContext";
|
||||
import { Suspense } from "react";
|
||||
|
||||
export default function LoginModal({
|
||||
settings,
|
||||
@@ -26,6 +28,8 @@ export default function LoginModal({
|
||||
const [error, setError] = useState("");
|
||||
const [busy, setBusy] = useState(false);
|
||||
const formId = useId();
|
||||
const authActions = usePlatformUiCapability<AuthActionUiCapability>("auth.actions");
|
||||
const LoginHelp = authActions?.LoginHelp;
|
||||
|
||||
async function submit(event: React.FormEvent) {
|
||||
event.preventDefault();
|
||||
@@ -38,6 +42,7 @@ export default function LoginModal({
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : String(err));
|
||||
} finally {
|
||||
setPassword("");
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
@@ -64,6 +69,7 @@ export default function LoginModal({
|
||||
<PasswordField helpContextId="access.authentication.password" helpModuleId="access" value={password} autoComplete="current-password" onValueChange={setPassword} />
|
||||
</FormField>
|
||||
</FormLayout>
|
||||
{LoginHelp && <Suspense fallback={null}><LoginHelp settings={settings} onNavigate={onClose} /></Suspense>}
|
||||
</Dialog>);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user