Use correct field for authentication of e-mail server (#2706)
This commit is contained in:
parent
d2a56a0ae7
commit
0d0e086913
1 changed files with 13 additions and 19 deletions
|
@ -56,7 +56,7 @@ export const RealmSettingsEmailTab = ({
|
||||||
|
|
||||||
const authenticationEnabled = useWatch({
|
const authenticationEnabled = useWatch({
|
||||||
control,
|
control,
|
||||||
name: "smtpServer.authentication",
|
name: "smtpServer.auth",
|
||||||
defaultValue: "",
|
defaultValue: "",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -78,25 +78,19 @@ export const RealmSettingsEmailTab = ({
|
||||||
};
|
};
|
||||||
|
|
||||||
const testConnection = async () => {
|
const testConnection = async () => {
|
||||||
|
const toNumber = (value: string) => Number(value);
|
||||||
|
const toBoolean = (value: string) => value === true.toString();
|
||||||
|
const valueMapper = new Map<string, (value: string) => unknown>([
|
||||||
|
["port", toNumber],
|
||||||
|
["ssl", toBoolean],
|
||||||
|
["starttls", toBoolean],
|
||||||
|
["auth", toBoolean],
|
||||||
|
]);
|
||||||
|
|
||||||
const serverSettings = { ...getValues()["smtpServer"] };
|
const serverSettings = { ...getValues()["smtpServer"] };
|
||||||
|
|
||||||
// Code below uses defensive coding as the server configuration uses an ambiguous record type.
|
for (const [key, mapperFn] of valueMapper.entries()) {
|
||||||
if (typeof serverSettings.port === "string") {
|
serverSettings[key] = mapperFn(serverSettings[key]);
|
||||||
serverSettings.port = Number(serverSettings.port);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof serverSettings.ssl === "string") {
|
|
||||||
serverSettings.ssl = serverSettings.ssl === true.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof serverSettings.starttls === "string") {
|
|
||||||
serverSettings.starttls = serverSettings.starttls === true.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
// For some reason the API wants a duplicate field for the authentication status.
|
|
||||||
// Somebody thought this was a good idea, so here we are.
|
|
||||||
if (serverSettings.authentication === true.toString()) {
|
|
||||||
serverSettings.auth = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -321,7 +315,7 @@ export const RealmSettingsEmailTab = ({
|
||||||
fieldId="kc-authentication"
|
fieldId="kc-authentication"
|
||||||
>
|
>
|
||||||
<Controller
|
<Controller
|
||||||
name="smtpServer.authentication"
|
name="smtpServer.auth"
|
||||||
control={control}
|
control={control}
|
||||||
defaultValue=""
|
defaultValue=""
|
||||||
render={({ onChange, value }) => (
|
render={({ onChange, value }) => (
|
||||||
|
|
Loading…
Reference in a new issue