Client: Improved scanner error if not HTTPS
This commit is contained in:
@@ -55,9 +55,14 @@ const QRCodeScannerModal: React.FC = () => {
|
|||||||
}
|
}
|
||||||
onDecode={onScan}
|
onDecode={onScan}
|
||||||
onError={(error: Error) => {
|
onError={(error: Error) => {
|
||||||
|
console.error(error);
|
||||||
if (error.name === "NotAllowedError") {
|
if (error.name === "NotAllowedError") {
|
||||||
setLastError(t("scanner.error.notAllowed"));
|
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"));
|
setLastError(t("scanner.error.insecureContext"));
|
||||||
} else if (error.name === "StreamApiNotSupportedError") {
|
} else if (error.name === "StreamApiNotSupportedError") {
|
||||||
setLastError(t("scanner.error.streamApiNotSupported"));
|
setLastError(t("scanner.error.streamApiNotSupported"));
|
||||||
|
|||||||
Reference in New Issue
Block a user