afix username/password fields
This commit is contained in:
parent
e565b3a3f8
commit
0a7387be6c
1 changed files with 9 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
||||||
import React, { useContext, useEffect, useState } from "react";
|
import React, { useContext, useEffect, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Controller, useForm } from "react-hook-form";
|
import { Controller, useForm, useWatch } from "react-hook-form";
|
||||||
import {
|
import {
|
||||||
ActionGroup,
|
ActionGroup,
|
||||||
AlertVariant,
|
AlertVariant,
|
||||||
|
@ -42,7 +42,6 @@ export const RealmSettingsEmailTab = ({
|
||||||
const { addAlert } = useAlerts();
|
const { addAlert } = useAlerts();
|
||||||
const { whoAmI } = useContext(WhoAmIContext);
|
const { whoAmI } = useContext(WhoAmIContext);
|
||||||
|
|
||||||
const [isAuthenticationEnabled, setAuthenticationEnabled] = useState("true");
|
|
||||||
const [realm, setRealm] = useState(initialRealm);
|
const [realm, setRealm] = useState(initialRealm);
|
||||||
const [userEmailModalOpen, setUserEmailModalOpen] = useState(false);
|
const [userEmailModalOpen, setUserEmailModalOpen] = useState(false);
|
||||||
const [currentUser, setCurrentUser] = useState<UserRepresentation>();
|
const [currentUser, setCurrentUser] = useState<UserRepresentation>();
|
||||||
|
@ -61,6 +60,12 @@ export const RealmSettingsEmailTab = ({
|
||||||
const watchFromValue = watch("smtpServer.from", "");
|
const watchFromValue = watch("smtpServer.from", "");
|
||||||
const watchHostValue = watch("smtpServer.host", "");
|
const watchHostValue = watch("smtpServer.host", "");
|
||||||
|
|
||||||
|
const authenticationEnabled = useWatch({
|
||||||
|
control,
|
||||||
|
name: "smtpServer.authentication",
|
||||||
|
defaultValue: realm?.smtpServer!.authentication,
|
||||||
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
reset();
|
reset();
|
||||||
}, [realm]);
|
}, [realm]);
|
||||||
|
@ -329,7 +334,7 @@ export const RealmSettingsEmailTab = ({
|
||||||
<Controller
|
<Controller
|
||||||
name="smtpServer.authentication"
|
name="smtpServer.authentication"
|
||||||
control={control}
|
control={control}
|
||||||
defaultValue="true"
|
defaultValue={authenticationEnabled}
|
||||||
render={({ onChange, value }) => (
|
render={({ onChange, value }) => (
|
||||||
<Switch
|
<Switch
|
||||||
id="kc-authentication"
|
id="kc-authentication"
|
||||||
|
@ -339,13 +344,12 @@ export const RealmSettingsEmailTab = ({
|
||||||
isChecked={value === "true"}
|
isChecked={value === "true"}
|
||||||
onChange={(value) => {
|
onChange={(value) => {
|
||||||
onChange("" + value);
|
onChange("" + value);
|
||||||
setAuthenticationEnabled(String(value));
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
{isAuthenticationEnabled === "true" && (
|
{authenticationEnabled === "true" && (
|
||||||
<>
|
<>
|
||||||
<FormGroup
|
<FormGroup
|
||||||
label={t("username")}
|
label={t("username")}
|
||||||
|
|
Loading…
Reference in a new issue