Browse Source

Force tls when seved over https

pull/39/head
Sacha Weatherstone 4 years ago
parent
commit
93ad24f6e1
No known key found for this signature in database GPG Key ID: 7AB2D7E206124B31
  1. 5
      src/components/PageComponents/Connect/HTTP.tsx
  2. 3
      src/components/form/Toggle.tsx

5
src/components/PageComponents/Connect/HTTP.tsx

@ -21,14 +21,14 @@ export const HTTP = (): JSX.Element => {
}>({
defaultValues: {
ip: "meshtastic.local",
tls: false,
tls: location.protocol === "https:",
},
});
const TLSEnabled = useWatch({
control,
name: "tls",
defaultValue: false,
defaultValue: location.protocol === "https:",
});
const onSubmit = handleSubmit((data) => {
@ -63,6 +63,7 @@ export const HTTP = (): JSX.Element => {
<Toggle
label="Use TLS"
description="Description"
disabled={location.protocol === "https:"}
checked={value}
{...rest}
/>

3
src/components/form/Toggle.tsx

@ -6,6 +6,7 @@ export interface ToggleProps {
label: string;
description: string;
checked: boolean;
disabled?: boolean;
onChange?: (checked: boolean) => void;
}
@ -13,6 +14,7 @@ export const Toggle = ({
label,
description,
checked,
disabled,
onChange,
}: ToggleProps): JSX.Element => {
return (
@ -31,6 +33,7 @@ export const Toggle = ({
</span>
<Switch
checked={checked}
disabled={disabled}
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 ${
checked ? "bg-indigo-600" : "bg-gray-200"

Loading…
Cancel
Save