Client: Improved scanner error if not HTTPS

This commit is contained in:
Donkie
2023-08-08 21:31:45 +02:00
parent f552affa98
commit 6ca18b8f94

View File

@@ -55,9 +55,14 @@ const QRCodeScannerModal: React.FC = () => {
}
onDecode={onScan}
onError={(error: Error) => {
console.error(error);
if (error.name === "NotAllowedError") {
setLastError(t("scanner.error.notAllowed"));
} else if (error.name === "InsecureContextError") {
} else if (
error.name === "InsecureContextError" ||
(location.protocol !== "https:" &&
navigator.mediaDevices === undefined)
) {
setLastError(t("scanner.error.insecureContext"));
} else if (error.name === "StreamApiNotSupportedError") {
setLastError(t("scanner.error.streamApiNotSupported"));