diff --git a/www/window/AddTfaRecovery.js b/www/window/AddTfaRecovery.js index 8d6ee51a..b63e8576 100644 --- a/www/window/AddTfaRecovery.js +++ b/www/window/AddTfaRecovery.js @@ -27,6 +27,7 @@ Ext.define('PBS.window.AddTfaRecovery', { let values = response.result.data.recovery.join("\n"); Ext.create('PBS.window.TfaRecoveryShow', { autoShow: true, + userid: this.getViewModel().get('userid'), values, }); }, @@ -182,5 +183,42 @@ Ext.define('PBS.window.TfaRecoveryShow', { iconCls: 'fa fa-clipboard', text: gettext('Copy Recovery Keys'), }, + { + handler: function(b) { + let win = this.up('window'); + win.paperkeys(win.values, win.userid); + }, + iconCls: 'fa fa-print', + text: gettext('Print Recovery Keys'), + }, ], + paperkeys: function(keyString, userid) { + let me = this; + + let printFrame = document.createElement("iframe"); + Object.assign(printFrame.style, { + position: "fixed", + right: "0", + bottom: "0", + width: "0", + height: "0", + border: "0", + }); + const host = document.location.host; + const title = document.title; + const html = ` +

Recovery Keys for '${userid}' - ${title} (${host})

+

+${keyString} +

+ `; + + printFrame.src = "data:text/html;base64," + btoa(html); + document.body.appendChild(printFrame); + }, });