FIX: Do not search for a paper key if it does not exist.

FIX: Do not search for a paper key if it does not exist.

diff --git a/assets/javascripts/lib/discourse.js.es6 b/assets/javascripts/lib/discourse.js.es6
index ecc8fe7..f2c21bf 100644
--- a/assets/javascripts/lib/discourse.js.es6
+++ b/assets/javascripts/lib/discourse.js.es6
@@ -262,12 +262,13 @@ export function activateEncrypt(currentUser, passphrase) {
 
   // Importing from a paper key.
   const spacePos = passphrase.indexOf(" ");
-  const firstWord = spacePos && passphrase.substr(0, spacePos);
-  const label = "paper_" + firstWord.toLowerCase();
-  if (privateKeys[label]) {
-    promise = promise.catch(() =>
-      importIdentity(privateKeys[label], passphrase)
-    );
+  if (spacePos) {
+    const label = "paper_" + passphrase.substr(0, spacePos).toLowerCase();
+    if (privateKeys[label]) {
+      promise = promise.catch(() =>
+        importIdentity(privateKeys[label], passphrase)
+      );
+    }
   }
 
   // Importing from a device key.

GitHub sha: b428e0d3