Skip to content

Commit

Permalink
Feat: Show fixed amount of asterisks if the user has password
Browse files Browse the repository at this point in the history
Show eight asterisks if the user has password set.

Fixes: freeipa#369

Signed-off-by: Michal Polovka <[email protected]>
  • Loading branch information
miskopo committed May 16, 2024
1 parent bddcf3f commit 30f711c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/components/UserSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ const UserSettings = (props: PropsToUserSettings) => {
uid={props.user.uid}
isOpen={isResetPasswordModalOpen}
onClose={() => setIsResetPasswordModalOpen(false)}
onRefresh={props.onRefresh}
/>
<IssueNewCertificate
isOpen={isNewCertificateModalOpen}
Expand Down
11 changes: 8 additions & 3 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, { useState } from "react";
import React, { useEffect, useState } from "react";
// PatternFly
import {
Flex,
Expand Down Expand Up @@ -44,8 +44,13 @@ interface PropsToUsersAccountSettings {
}

const UsersAccountSettings = (props: PropsToUsersAccountSettings) => {
// TODO: Handle the `has_password` variable (boolean) by another Ipa component
const [password] = useState("");
// Use asterisks if a password is set, leave empty otherwise
const [password, setPassword] = useState<string>("");
useEffect(() => {
if (props.user.has_password) {
setPassword("********");
}
}, [props.user]);

// Get 'ipaObject' and 'recordOnChange' to use in 'IpaTextInput'
const { ipaObject, recordOnChange } = asRecord(
Expand Down
3 changes: 3 additions & 0 deletions src/components/modals/ResetPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface PropsToResetPassword {
uid: string | undefined;
isOpen: boolean;
onClose: () => void;
onRefresh: () => void;
}

const ResetPassword = (props: PropsToResetPassword) => {
Expand Down Expand Up @@ -150,6 +151,8 @@ const ResetPassword = (props: PropsToResetPassword) => {
if (response.data.result) {
// Close modal
resetFieldsAndCloseModal();
// Refresh data
props.onRefresh();
// Set alert: success
alerts.addAlert(
"reset-password-success",
Expand Down

0 comments on commit 30f711c

Please sign in to comment.