Skip to content

Commit

Permalink
Simplify has_password checking in user settings
Browse files Browse the repository at this point in the history
Do not use UseState for password checking and use ternary operator
instead.

Discussion: freeipa#375 (comment)
Related to: freeipa#369

Signed-off-by: Michal Polovka <[email protected]>
  • Loading branch information
miskopo committed May 16, 2024
1 parent 3febc11 commit fdefd60
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/components/UsersSections/UsersAccountSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import React, { useEffect, useState } from "react";
import React, { useState } from "react";
// PatternFly
import {
Flex,
Expand Down Expand Up @@ -45,12 +45,7 @@ interface PropsToUsersAccountSettings {

const UsersAccountSettings = (props: PropsToUsersAccountSettings) => {
// Use asterisks if a password is set, leave empty otherwise
const [password, setPassword] = useState<string>("");
useEffect(() => {
if (props.user.has_password) {
setPassword("********");
}
}, [props.user]);
const password = props.user.has_password ? "********" : "";

// Get 'ipaObject' and 'recordOnChange' to use in 'IpaTextInput'
const { ipaObject, recordOnChange } = asRecord(
Expand Down

0 comments on commit fdefd60

Please sign in to comment.