From 6ca18b8f94330d0ea01f5a96ef147c7fb111ff02 Mon Sep 17 00:00:00 2001 From: Donkie Date: Tue, 8 Aug 2023 21:31:45 +0200 Subject: [PATCH] Client: Improved scanner error if not HTTPS --- client/src/components/qrCodeScanner.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/src/components/qrCodeScanner.tsx b/client/src/components/qrCodeScanner.tsx index aa80e80..cd09006 100644 --- a/client/src/components/qrCodeScanner.tsx +++ b/client/src/components/qrCodeScanner.tsx @@ -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"));