Force tls when seved over https
This commit is contained in:
@@ -21,14 +21,14 @@ export const HTTP = (): JSX.Element => {
|
|||||||
}>({
|
}>({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
ip: "meshtastic.local",
|
ip: "meshtastic.local",
|
||||||
tls: false,
|
tls: location.protocol === "https:",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const TLSEnabled = useWatch({
|
const TLSEnabled = useWatch({
|
||||||
control,
|
control,
|
||||||
name: "tls",
|
name: "tls",
|
||||||
defaultValue: false,
|
defaultValue: location.protocol === "https:",
|
||||||
});
|
});
|
||||||
|
|
||||||
const onSubmit = handleSubmit((data) => {
|
const onSubmit = handleSubmit((data) => {
|
||||||
@@ -63,6 +63,7 @@ export const HTTP = (): JSX.Element => {
|
|||||||
<Toggle
|
<Toggle
|
||||||
label="Use TLS"
|
label="Use TLS"
|
||||||
description="Description"
|
description="Description"
|
||||||
|
disabled={location.protocol === "https:"}
|
||||||
checked={value}
|
checked={value}
|
||||||
{...rest}
|
{...rest}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ export interface ToggleProps {
|
|||||||
label: string;
|
label: string;
|
||||||
description: string;
|
description: string;
|
||||||
checked: boolean;
|
checked: boolean;
|
||||||
|
disabled?: boolean;
|
||||||
onChange?: (checked: boolean) => void;
|
onChange?: (checked: boolean) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -13,6 +14,7 @@ export const Toggle = ({
|
|||||||
label,
|
label,
|
||||||
description,
|
description,
|
||||||
checked,
|
checked,
|
||||||
|
disabled,
|
||||||
onChange,
|
onChange,
|
||||||
}: ToggleProps): JSX.Element => {
|
}: ToggleProps): JSX.Element => {
|
||||||
return (
|
return (
|
||||||
@@ -31,6 +33,7 @@ export const Toggle = ({
|
|||||||
</span>
|
</span>
|
||||||
<Switch
|
<Switch
|
||||||
checked={checked}
|
checked={checked}
|
||||||
|
disabled={disabled}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
className={`relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 ${
|
className={`relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 ${
|
||||||
checked ? "bg-indigo-600" : "bg-gray-200"
|
checked ? "bg-indigo-600" : "bg-gray-200"
|
||||||
|
|||||||
Reference in New Issue
Block a user