From f4e72aae8a9f08149ec1adcd50ab1df5dfe30e6e Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 18 Oct 2017 11:50:21 -0400 Subject: [PATCH] autofill card expiration --- .../app/vault/vaultViewCipherController.js | 8 +++++ .../app/vault/views/vaultViewCipher.html | 4 ++- src/services/autofillService.js | 31 +++++++++++++++---- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/popup/app/vault/vaultViewCipherController.js b/src/popup/app/vault/vaultViewCipherController.js index fd618e74f6..3c3bf95665 100644 --- a/src/popup/app/vault/vaultViewCipherController.js +++ b/src/popup/app/vault/vaultViewCipherController.js @@ -195,6 +195,14 @@ angular } }); + $scope.formatYear = function (year) { + if (year.length == 2) { + return '20' + year; + } + + return year; + }; + function totpUpdateCode() { if ($scope.cipher.type !== constantsService.cipherType.login || !$scope.cipher.login.totp) { return; diff --git a/src/popup/app/vault/views/vaultViewCipher.html b/src/popup/app/vault/views/vaultViewCipher.html index 71a10065f3..412131cdf7 100644 --- a/src/popup/app/vault/views/vaultViewCipher.html +++ b/src/popup/app/vault/views/vaultViewCipher.html @@ -111,7 +111,9 @@
{{i18n.expiration}} - {{cipher.card.expMonth ? ('0' + cipher.card.expMonth).slice(-2) : '-'}}/{{cipher.card.expYear || '-'}} + {{cipher.card.expMonth ? ('0' + cipher.card.expMonth).slice(-2) : '__'}} + / + {{cipher.card.expYear ? formatYear(cipher.card.expYear) : '____'}}
diff --git a/src/services/autofillService.js b/src/services/autofillService.js index 1b927caed2..a2826743c6 100644 --- a/src/services/autofillService.js +++ b/src/services/autofillService.js @@ -365,6 +365,12 @@ function initAutofill() { fillFields.number = f; } break; + case 'cc-exp': case 'ccexp': case 'cardexp': case 'card-exp': case 'cc-expiration': + case 'ccexpiration': case 'card-expiration': case 'cardexpiration': + if (!fillFields.exp) { + fillFields.exp = f; + } + break; case 'exp-month': case 'expmonth': case 'ccexpmonth': case 'cc-exp-month': case 'cc-month': case 'ccmonth': case 'card-month': case 'cardmonth': if (!fillFields.expMonth) { @@ -395,12 +401,25 @@ function initAutofill() { } } - makeScriptAction(fillScript, options.cipher.card, fillFields, filledFields, 'cardholderName'); - makeScriptAction(fillScript, options.cipher.card, fillFields, filledFields, 'number'); - makeScriptAction(fillScript, options.cipher.card, fillFields, filledFields, 'expMonth'); - makeScriptAction(fillScript, options.cipher.card, fillFields, filledFields, 'expYear'); - makeScriptAction(fillScript, options.cipher.card, fillFields, filledFields, 'code'); - makeScriptAction(fillScript, options.cipher.card, fillFields, filledFields, 'brand'); + var card = options.cipher.card; + makeScriptAction(fillScript, card, fillFields, filledFields, 'cardholderName'); + makeScriptAction(fillScript, card, fillFields, filledFields, 'number'); + makeScriptAction(fillScript, card, fillFields, filledFields, 'expMonth'); + makeScriptAction(fillScript, card, fillFields, filledFields, 'expYear'); + makeScriptAction(fillScript, card, fillFields, filledFields, 'code'); + makeScriptAction(fillScript, card, fillFields, filledFields, 'brand'); + + if (fillFields.exp && card.expMonth && card.expYear) { + var year = card.expYear; + if (year.length == 2) { + year = '20' + year; + } + var exp = year + '-' + ('0' + card.expMonth).slice(-2); + + filledFields[fillFields.exp.opid] = fillFields.exp; + fillScript.script.push(['click_on_opid', fillFields.exp.opid]); + fillScript.script.push(['fill_by_opid', fillFields.exp.opid, exp]); + } return fillScript; }