Fixes #32547 Signed-off-by: Thomas Darimont <thomas.darimont@googlemail.com>
This commit is contained in:
parent
7625e3b4ea
commit
3fe5d4847a
2 changed files with 8 additions and 12 deletions
|
@ -1,6 +1,5 @@
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { TimeSelectorControl } from "../../components/time-selector/TimeSelectorControl";
|
import { TimeSelectorControl } from "../../components/time-selector/TimeSelectorControl";
|
||||||
import { credResetFormDefaultValues } from "./ResetCredentialDialog";
|
|
||||||
|
|
||||||
export const LifespanField = () => {
|
export const LifespanField = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -12,9 +11,7 @@ export const LifespanField = () => {
|
||||||
labelIcon={t("lifespanHelp")}
|
labelIcon={t("lifespanHelp")}
|
||||||
units={["minute", "hour", "day"]}
|
units={["minute", "hour", "day"]}
|
||||||
menuAppendTo="parent"
|
menuAppendTo="parent"
|
||||||
controller={{
|
controller={{}}
|
||||||
defaultValue: credResetFormDefaultValues.lifespan,
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,6 +8,7 @@ import { useAlerts } from "@keycloak/keycloak-ui-shared";
|
||||||
import { ConfirmDialogModal } from "../../components/confirm-dialog/ConfirmDialog";
|
import { ConfirmDialogModal } from "../../components/confirm-dialog/ConfirmDialog";
|
||||||
import { LifespanField } from "./LifespanField";
|
import { LifespanField } from "./LifespanField";
|
||||||
import { RequiredActionMultiSelect } from "./RequiredActionMultiSelect";
|
import { RequiredActionMultiSelect } from "./RequiredActionMultiSelect";
|
||||||
|
import { useRealm } from "../../context/realm-context/RealmContext";
|
||||||
|
|
||||||
type ResetCredentialDialogProps = {
|
type ResetCredentialDialogProps = {
|
||||||
userId: string;
|
userId: string;
|
||||||
|
@ -16,12 +17,7 @@ type ResetCredentialDialogProps = {
|
||||||
|
|
||||||
type CredentialResetForm = {
|
type CredentialResetForm = {
|
||||||
actions: RequiredActionAlias[];
|
actions: RequiredActionAlias[];
|
||||||
lifespan: number;
|
lifespan: number | undefined;
|
||||||
};
|
|
||||||
|
|
||||||
export const credResetFormDefaultValues: CredentialResetForm = {
|
|
||||||
actions: [],
|
|
||||||
lifespan: 43200, // 12 hours
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ResetCredentialDialog = ({
|
export const ResetCredentialDialog = ({
|
||||||
|
@ -29,10 +25,13 @@ export const ResetCredentialDialog = ({
|
||||||
onClose,
|
onClose,
|
||||||
}: ResetCredentialDialogProps) => {
|
}: ResetCredentialDialogProps) => {
|
||||||
const { adminClient } = useAdminClient();
|
const { adminClient } = useAdminClient();
|
||||||
|
const { realmRepresentation: realm } = useRealm();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const form = useForm<CredentialResetForm>({
|
const form = useForm<CredentialResetForm>({
|
||||||
defaultValues: credResetFormDefaultValues,
|
defaultValues: {
|
||||||
|
actions: [],
|
||||||
|
lifespan: realm?.actionTokenGeneratedByAdminLifespan,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
const { handleSubmit, control } = form;
|
const { handleSubmit, control } = form;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue