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:
Erik Jan de Wit 2021-08-17 14:58:07 +02:00 committed by GitHub
parent f93d478f44
commit 2581da0765
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 10 deletions

View file

@ -8,7 +8,15 @@ import {
} from "@patternfly/react-core";
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 [hidePassword, setHidePassword] = useState(true);
return (
@ -18,6 +26,7 @@ const PasswordInputBase = ({ innerRef, ...rest }: TextInputProps) => {
type={hidePassword ? "password" : "text"}
ref={innerRef}
/>
{hasReveal && (
<Button
variant="control"
aria-label={t("showPassword")}
@ -25,12 +34,13 @@ const PasswordInputBase = ({ innerRef, ...rest }: TextInputProps) => {
>
{hidePassword ? <EyeIcon /> : <EyeSlashIcon />}
</Button>
)}
</InputGroup>
);
};
export const PasswordInput = React.forwardRef(
(props: TextInputProps, ref: React.Ref<HTMLInputElement>) => (
(props: PasswordInputProps, ref: React.Ref<HTMLInputElement>) => (
<PasswordInputBase
{...props}
innerRef={ref as React.MutableRefObject<any>}

View file

@ -298,7 +298,7 @@ export const UserFederationLdapSettings = () => {
]}
>
<LdapSettingsGeneral form={form} />
<LdapSettingsConnection form={form} />
<LdapSettingsConnection form={form} edit={!!id} />
<LdapSettingsSearching form={form} />
<LdapSettingsSynchronization form={form} />
<LdapSettingsKerberosIntegration form={form} />

View file

@ -27,6 +27,7 @@ export type LdapSettingsConnectionProps = {
form: UseFormMethods;
showSectionHeading?: boolean;
showSectionDescription?: boolean;
edit?: boolean;
};
const testLdapProperties: Array<keyof TestLdapConnectionRepresentation> = [
@ -43,6 +44,7 @@ export const LdapSettingsConnection = ({
form,
showSectionHeading = false,
showSectionDescription = false,
edit = false,
}: LdapSettingsConnectionProps) => {
const { t } = useTranslation("user-federation");
const { t: helpText } = useTranslation("user-federation-help");
@ -319,6 +321,7 @@ export const LdapSettingsConnection = ({
isRequired
>
<PasswordInput
hasReveal={!edit}
isRequired
id="kc-console-bind-credentials"
data-testid="ldap-bind-credentials"