change to TextInput when editing (#991)
* change to TextInput when editing as keycloak doesn't store the password as clear text fixes: #971 * now part of the password field
This commit is contained in:
parent
f93d478f44
commit
2581da0765
3 changed files with 23 additions and 10 deletions
|
@ -8,7 +8,15 @@ import {
|
||||||
} from "@patternfly/react-core";
|
} from "@patternfly/react-core";
|
||||||
import { EyeIcon, EyeSlashIcon } from "@patternfly/react-icons";
|
import { EyeIcon, EyeSlashIcon } from "@patternfly/react-icons";
|
||||||
|
|
||||||
const PasswordInputBase = ({ innerRef, ...rest }: TextInputProps) => {
|
type PasswordInputProps = TextInputProps & {
|
||||||
|
hasReveal?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
const PasswordInputBase = ({
|
||||||
|
hasReveal = true,
|
||||||
|
innerRef,
|
||||||
|
...rest
|
||||||
|
}: PasswordInputProps) => {
|
||||||
const { t } = useTranslation("common-help");
|
const { t } = useTranslation("common-help");
|
||||||
const [hidePassword, setHidePassword] = useState(true);
|
const [hidePassword, setHidePassword] = useState(true);
|
||||||
return (
|
return (
|
||||||
|
@ -18,6 +26,7 @@ const PasswordInputBase = ({ innerRef, ...rest }: TextInputProps) => {
|
||||||
type={hidePassword ? "password" : "text"}
|
type={hidePassword ? "password" : "text"}
|
||||||
ref={innerRef}
|
ref={innerRef}
|
||||||
/>
|
/>
|
||||||
|
{hasReveal && (
|
||||||
<Button
|
<Button
|
||||||
variant="control"
|
variant="control"
|
||||||
aria-label={t("showPassword")}
|
aria-label={t("showPassword")}
|
||||||
|
@ -25,12 +34,13 @@ const PasswordInputBase = ({ innerRef, ...rest }: TextInputProps) => {
|
||||||
>
|
>
|
||||||
{hidePassword ? <EyeIcon /> : <EyeSlashIcon />}
|
{hidePassword ? <EyeIcon /> : <EyeSlashIcon />}
|
||||||
</Button>
|
</Button>
|
||||||
|
)}
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const PasswordInput = React.forwardRef(
|
export const PasswordInput = React.forwardRef(
|
||||||
(props: TextInputProps, ref: React.Ref<HTMLInputElement>) => (
|
(props: PasswordInputProps, ref: React.Ref<HTMLInputElement>) => (
|
||||||
<PasswordInputBase
|
<PasswordInputBase
|
||||||
{...props}
|
{...props}
|
||||||
innerRef={ref as React.MutableRefObject<any>}
|
innerRef={ref as React.MutableRefObject<any>}
|
||||||
|
|
|
@ -298,7 +298,7 @@ export const UserFederationLdapSettings = () => {
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<LdapSettingsGeneral form={form} />
|
<LdapSettingsGeneral form={form} />
|
||||||
<LdapSettingsConnection form={form} />
|
<LdapSettingsConnection form={form} edit={!!id} />
|
||||||
<LdapSettingsSearching form={form} />
|
<LdapSettingsSearching form={form} />
|
||||||
<LdapSettingsSynchronization form={form} />
|
<LdapSettingsSynchronization form={form} />
|
||||||
<LdapSettingsKerberosIntegration form={form} />
|
<LdapSettingsKerberosIntegration form={form} />
|
||||||
|
|
|
@ -27,6 +27,7 @@ export type LdapSettingsConnectionProps = {
|
||||||
form: UseFormMethods;
|
form: UseFormMethods;
|
||||||
showSectionHeading?: boolean;
|
showSectionHeading?: boolean;
|
||||||
showSectionDescription?: boolean;
|
showSectionDescription?: boolean;
|
||||||
|
edit?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const testLdapProperties: Array<keyof TestLdapConnectionRepresentation> = [
|
const testLdapProperties: Array<keyof TestLdapConnectionRepresentation> = [
|
||||||
|
@ -43,6 +44,7 @@ export const LdapSettingsConnection = ({
|
||||||
form,
|
form,
|
||||||
showSectionHeading = false,
|
showSectionHeading = false,
|
||||||
showSectionDescription = false,
|
showSectionDescription = false,
|
||||||
|
edit = false,
|
||||||
}: LdapSettingsConnectionProps) => {
|
}: LdapSettingsConnectionProps) => {
|
||||||
const { t } = useTranslation("user-federation");
|
const { t } = useTranslation("user-federation");
|
||||||
const { t: helpText } = useTranslation("user-federation-help");
|
const { t: helpText } = useTranslation("user-federation-help");
|
||||||
|
@ -319,6 +321,7 @@ export const LdapSettingsConnection = ({
|
||||||
isRequired
|
isRequired
|
||||||
>
|
>
|
||||||
<PasswordInput
|
<PasswordInput
|
||||||
|
hasReveal={!edit}
|
||||||
isRequired
|
isRequired
|
||||||
id="kc-console-bind-credentials"
|
id="kc-console-bind-credentials"
|
||||||
data-testid="ldap-bind-credentials"
|
data-testid="ldap-bind-credentials"
|
||||||
|
|
Loading…
Reference in a new issue