forked from jsnbuchanan/crowd-funder-for-time-pwa
fix: add HTTPS requirement check for camera access
- Check for secure context before attempting camera access - Show clear user feedback when HTTPS is required - Prevent confusing permission errors on insecure connections
This commit is contained in:
@@ -41,6 +41,12 @@ export class WebDialogQRScanner implements QRScannerService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async isSupported(): Promise<boolean> {
|
async isSupported(): Promise<boolean> {
|
||||||
|
// Check for secure context first
|
||||||
|
if (!window.isSecureContext) {
|
||||||
|
logger.warn("Camera access requires HTTPS (secure context)");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Then check for camera API support
|
||||||
return !!(navigator.mediaDevices && navigator.mediaDevices.getUserMedia);
|
return !!(navigator.mediaDevices && navigator.mediaDevices.getUserMedia);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -214,6 +214,19 @@ export default class ContactQRScanShow extends Vue {
|
|||||||
|
|
||||||
const scanner = QRScannerFactory.getInstance();
|
const scanner = QRScannerFactory.getInstance();
|
||||||
|
|
||||||
|
// Check if scanning is supported first
|
||||||
|
if (!(await scanner.isSupported())) {
|
||||||
|
this.error = "Camera access requires HTTPS. Please use a secure connection.";
|
||||||
|
this.isScanning = false;
|
||||||
|
this.$notify({
|
||||||
|
group: "alert",
|
||||||
|
type: "warning",
|
||||||
|
title: "HTTPS Required",
|
||||||
|
text: "Camera access requires a secure (HTTPS) connection"
|
||||||
|
}, 5000);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Check permissions first
|
// Check permissions first
|
||||||
if (!(await scanner.checkPermissions())) {
|
if (!(await scanner.checkPermissions())) {
|
||||||
const granted = await scanner.requestPermissions();
|
const granted = await scanner.requestPermissions();
|
||||||
|
|||||||
Reference in New Issue
Block a user