FIX: Properly generate device keys.

FIX: Properly generate device keys.

‘device’ flag was not properly propagated.

diff --git a/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.js.es6 b/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.js.es6
index 32ec76d..21776bd 100644
--- a/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.js.es6
+++ b/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.js.es6
@@ -170,22 +170,24 @@ export default {
     },
 
     export() {
-      showModal("export-keypair").set("model", this.model);
+      showModal("export-keypair", { model: this.model });
     },
 
     reset() {
-      showModal("reset-keypair").set("model", this.model);
+      showModal("reset-keypair", { model: this.model });
     },
 
     generatePaperKey(device) {
-      showModal("generate-paperkey").setProperties({
-        model: this.model,
-        device
+      showModal("generate-paperkey", {
+        model: {
+          user: this.model,
+          device
+        }
       });
     },
 
     managePaperKeys() {
-      showModal("manage-paperkeys").set("model", this.model);
+      showModal("manage-paperkeys", { model: this.model });
     }
   }
 };
diff --git a/assets/javascripts/discourse/controllers/generate-paperkey.js.es6 b/assets/javascripts/discourse/controllers/generate-paperkey.js.es6
index e4b6c2d..6359cb7 100644
--- a/assets/javascripts/discourse/controllers/generate-paperkey.js.es6
+++ b/assets/javascripts/discourse/controllers/generate-paperkey.js.es6
@@ -7,9 +7,8 @@ import { exportIdentity } from "discourse/plugins/discourse-encrypt/lib/protocol
 export default Ember.Controller.extend(ModalFunctionality, {
   onShow() {
     this.set("inProgress", true);
-
     const paperKey = generatePaperKey();
-    const label = this.device
+    const label = this.model.device
       ? "device"
       : "paper_" + paperKey.substr(0, paperKey.indexOf(" ")).toLowerCase();
 
@@ -28,12 +27,12 @@ export default Ember.Controller.extend(ModalFunctionality, {
         });
       })
       .then(() => {
-        const privateKeys = this.model.custom_fields.encrypt_private
-          ? JSON.parse(this.model.custom_fields.encrypt_private)
+        const privateKeys = this.model.user.custom_fields.encrypt_private
+          ? JSON.parse(this.model.user.custom_fields.encrypt_private)
           : {};
         privateKeys[label] = true;
         this.set(
-          "model.custom_fields.encrypt_private",
+          "model.user.custom_fields.encrypt_private",
           JSON.stringify(privateKeys)
         );
       })
diff --git a/assets/javascripts/discourse/controllers/manage-paperkeys.js.es6 b/assets/javascripts/discourse/controllers/manage-paperkeys.js.es6
index bc82028..b538f61 100644
--- a/assets/javascripts/discourse/controllers/manage-paperkeys.js.es6
+++ b/assets/javascripts/discourse/controllers/manage-paperkeys.js.es6
@@ -20,9 +20,11 @@ export default Ember.Controller.extend(ModalFunctionality, {
 
   actions: {
     generatePaperKey() {
-      showModal("generate-paperkey").setProperties({
-        model: this.model,
-        device: false
+      showModal("generate-paperkey", {
+        model: {
+          user: this.model,
+          device: false
+        }
       });
     },

GitHub sha: 4d0dcce7