Skip to content

Commit

Permalink
Adapt the 'Password policy' subsection fields
Browse files Browse the repository at this point in the history
The fields of the 'Password policy' subsection
need to be adapted to synchronize wirh the data
from the `pwpolicy_show` JSON RPC method (previously
adapted in the RPC wrapper and used through the
`useUserSettingsData` custom hook).

Signed-off-by: Carla Martinez <[email protected]>
  • Loading branch information
carma12 committed Nov 13, 2023
1 parent b9d9741 commit 18ce46c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/components/UserSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ const UserSettings = (props: PropsToUserSettings) => {
id="password-policy"
text="Password policy"
/>
<UsersPasswordPolicy />
<UsersPasswordPolicy pwdPolicyData={props.pwPolicyData || []} />
<TitleLayout
key={3}
headingLevel="h2"
Expand Down
56 changes: 25 additions & 31 deletions src/components/UsersSections/UsersPasswordPolicy.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from "react";
import React from "react";
// PatternFly
import {
Flex,
Expand All @@ -8,18 +8,12 @@ import {
TextInput,
} from "@patternfly/react-core";

const UsersPasswordPolicy = () => {
// TODO: This state variables should update the user data via the IPA API (`pwpolicy_mod`)
const [maxLifetimeDays] = useState("");
const [minLifetimeHours] = useState("");
const [historySize] = useState("");
const [characterClasses] = useState("");
const [minLength] = useState("");
const [maxFailures] = useState("");
const [futureResetInterval] = useState("");
const [lockoutDuration] = useState("");
const [graceLoginLimit] = useState("");
interface PropsToPasswordPolicy {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
pwdPolicyData: Record<string, any>;
}

const UsersPasswordPolicy = (props: PropsToPasswordPolicy) => {
return (
<Flex direction={{ default: "column", md: "row" }}>
<FlexItem flex={{ default: "flex_1" }}>
Expand All @@ -28,20 +22,20 @@ const UsersPasswordPolicy = () => {
<TextInput
id="max-lifetime-days"
name="krbmaxpwdlife"
value={maxLifetimeDays}
value={props.pwdPolicyData.krbmaxpwdlife}
type="text"
aria-label="max lifetime in days"
isDisabled
readOnlyVariant="plain"
/>
</FormGroup>
<FormGroup label="Min lifetime (hours)" fieldId="mini-lifetime-hours">
<TextInput
id="min-lifetime-hours"
name="krbminpwdlife"
value={minLifetimeHours}
value={props.pwdPolicyData.krbminpwdlife}
type="text"
aria-label="min lifetime in hours"
isDisabled
readOnlyVariant="plain"
/>
</FormGroup>
<FormGroup
Expand All @@ -51,30 +45,30 @@ const UsersPasswordPolicy = () => {
<TextInput
id="history-size"
name="krbpwdhistorylength"
value={historySize}
value={props.pwdPolicyData.krbpwdhistorylength}
type="text"
aria-label="history size"
isDisabled
readOnlyVariant="plain"
/>
</FormGroup>
<FormGroup label="Character classes" fieldId="character-classes">
<TextInput
id="character-classes"
name="krbpwdmindiffchars"
value={characterClasses}
value={props.pwdPolicyData.krbpwdmindiffchars}
type="text"
aria-label="character classes"
isDisabled
readOnlyVariant="plain"
/>
</FormGroup>
<FormGroup label="Min length" fieldId="min-length">
<TextInput
id="min-length"
name="krbpwdminlength"
value={minLength}
value={props.pwdPolicyData.krbpwdminlength}
type="text"
aria-label="min length"
isDisabled
readOnlyVariant="plain"
/>
</FormGroup>
</Form>
Expand All @@ -84,11 +78,11 @@ const UsersPasswordPolicy = () => {
<FormGroup label="Max failures" fieldId="max-failures">
<TextInput
id="max-failures"
name="krbpwdminlength"
value={maxFailures}
name="krbpwdmaxfailure"
value={props.pwdPolicyData.krbpwdmaxfailure}
type="text"
aria-label="max failures"
isDisabled
readOnlyVariant="plain"
/>
</FormGroup>
<FormGroup
Expand All @@ -98,10 +92,10 @@ const UsersPasswordPolicy = () => {
<TextInput
id="future-reset-interval"
name="krbpwdfailurecountinterval"
value={futureResetInterval}
value={props.pwdPolicyData.krbpwdfailurecountinterval}
type="text"
aria-label="future reset interval in seconds"
isDisabled
readOnlyVariant="plain"
/>
</FormGroup>
<FormGroup
Expand All @@ -111,20 +105,20 @@ const UsersPasswordPolicy = () => {
<TextInput
id="lockout-duration"
name="krbpwdlockoutduration"
value={lockoutDuration}
value={props.pwdPolicyData.krbpwdlockoutduration}
type="text"
aria-label="lockout duration in seconds"
isDisabled
readOnlyVariant="plain"
/>
</FormGroup>
<FormGroup label="Grace login limit" fieldId="grace-login-limit">
<TextInput
id="grace-login-limit"
name="passwordgracelimit"
value={graceLoginLimit}
value={props.pwdPolicyData.passwordgracelimit}
type="text"
aria-label="grace login limit"
isDisabled
readOnlyVariant="plain"
/>
</FormGroup>
</Form>
Expand Down

0 comments on commit 18ce46c

Please sign in to comment.