Skip to content

Commit

Permalink
⏱ Allow copying of TOTP with a keyboard shortcut and button
Browse files Browse the repository at this point in the history
  • Loading branch information
zmilonas committed Jul 29, 2018
1 parent 4a4b478 commit 352f1e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
14 changes: 10 additions & 4 deletions services/unlockedState.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,16 @@ function UnlockedState($router, keepassReference, protectedMemory, settings, not
return; //listener can get registered multiple times
}

var textToPutOnClipboard = getAttribute(copyEntry, copyPart);
var fieldName = copyPart.charAt(0).toUpperCase() + copyPart.slice(1); // https://stackoverflow.com/a/1026087
copyEntry = null;
copyPart = null;
let fieldName, textToPutOnClipboard;
if (copyPart === 'userName' || copyPart === 'password') {
textToPutOnClipboard = getAttribute(copyEntry, copyPart);
fieldName = copyPart.charAt(0).toUpperCase() + copyPart.slice(1); // https://stackoverflow.com/a/1026087
} else {
fieldName = copyPart;
textToPutOnClipboard = copyEntry;
}
copyEntry = null;
copyPart = null;
e.clipboardData.setData('text/plain', textToPutOnClipboard);
e.preventDefault();

Expand Down
6 changes: 2 additions & 4 deletions src/components/EntryListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@
otp_value: "",
keyHandler: e => {
if ((e.ctrlKey || e.metaKey) && e.key == "/" && !e.altKey && !e.shiftKey) {
copyPlain = this.otp_value;
document.execCommand('copy')
copyPlain = undefined;
e.stopPropagation
this.copyOtp(e);
}
}
}
Expand Down Expand Up @@ -100,6 +97,7 @@
},
copyOtp(e) {
e.stopPropagation()
this.unlockedState.copyTotp(this.otp_value);
},
parseUrl(url) {
url = url.indexOf('http') < 0 ? 'http://' + url : url
Expand Down

0 comments on commit 352f1e5

Please sign in to comment.