Переглянути джерело

fix: Added alert for bad encryption key (#3998)

Ishan Sharma 3 роки тому
батько
коміт
e8b462cc31
2 змінених файлів з 6 додано та 1 видалено
  1. 4 0
      src/excalidraw-app/data/index.ts
  2. 2 1
      src/locales/en.json

+ 4 - 0
src/excalidraw-app/data/index.ts

@@ -137,6 +137,10 @@ export const decryptAESGEM = async (
 export const getCollaborationLinkData = (link: string) => {
   const hash = new URL(link).hash;
   const match = hash.match(/^#room=([a-zA-Z0-9_-]+),([a-zA-Z0-9_-]+)$/);
+  if (match && match[2].length !== 22) {
+    window.alert(t("alerts.invalidEncryptionKey"));
+    return null;
+  }
   return match ? { roomId: match[1], roomKey: match[2] } : null;
 };
 

+ 2 - 1
src/locales/en.json

@@ -157,7 +157,8 @@
     "imageDoesNotContainScene": "Importing images isn't supported at the moment.\n\nDid you want to import a scene? This image does not seem to contain any scene data. Have you enabled this during export?",
     "cannotRestoreFromImage": "Scene couldn't be restored from this image file",
     "invalidSceneUrl": "Couldn't import scene from the supplied URL. It's either malformed, or doesn't contain valid Excalidraw JSON data.",
-    "resetLibrary": "This will clear your library. Are you sure?"
+    "resetLibrary": "This will clear your library. Are you sure?",
+    "invalidEncryptionKey": "Encryption key must be of 22 characters. Live collaboration is disabled."
   },
   "toolBar": {
     "selection": "Selection",