mirror of
https://github.com/shuaiplus/nodewarden.git
synced 2026-08-05 06:50:10 +00:00
fix(totp): validate qr image uploads
This commit is contained in:
@@ -67,6 +67,8 @@ interface WebsiteRowProps {
|
|||||||
onRemove: (index: number) => void;
|
onRemove: (index: number) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const TOTP_QR_IMAGE_MAX_BYTES = 8 * 1024 * 1024;
|
||||||
|
|
||||||
function WebsiteRow(props: WebsiteRowProps) {
|
function WebsiteRow(props: WebsiteRowProps) {
|
||||||
const websiteMatchOptions = getWebsiteMatchOptions();
|
const websiteMatchOptions = getWebsiteMatchOptions();
|
||||||
|
|
||||||
@@ -208,6 +210,14 @@ export default function VaultEditor(props: VaultEditorProps) {
|
|||||||
|
|
||||||
const handleTotpQrFile = async (file: File | null) => {
|
const handleTotpQrFile = async (file: File | null) => {
|
||||||
if (!file) return;
|
if (!file) return;
|
||||||
|
if (file.type && !file.type.startsWith('image/')) {
|
||||||
|
setTotpQrStatus(t('txt_totp_qr_invalid_image_type'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (file.size > TOTP_QR_IMAGE_MAX_BYTES) {
|
||||||
|
setTotpQrStatus(t('txt_totp_qr_image_too_large'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
setTotpQrBusy(true);
|
setTotpQrBusy(true);
|
||||||
setTotpQrStatus(t('txt_totp_qr_scanning'));
|
setTotpQrStatus(t('txt_totp_qr_scanning'));
|
||||||
let bitmap: ImageBitmap | null = null;
|
let bitmap: ImageBitmap | null = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user