bug #4476 - fixes reoccurrence of recovery phrase in logs

Signed-off-by: Goran Jovic <goranjovic@gmail.com>
This commit is contained in:
Goran Jovic 2018-08-23 14:12:03 +02:00
parent e7a8dfc629
commit d46eec0bc8
No known key found for this signature in database
GPG Key ID: D429D1A9B2EB8A8E
3 changed files with 11 additions and 10 deletions

View File

@ -47,10 +47,11 @@
;;;; Handlers
(defn set-phrase [recovery-phrase {:keys [db]}]
{:db (update db :accounts/recover assoc
:passphrase (string/lower-case recovery-phrase)
:passphrase-valid? (not (check-phrase-errors recovery-phrase)))})
(defn set-phrase [masked-recovery-phrase {:keys [db]}]
(let [recovery-phrase (security/unmask masked-recovery-phrase)]
{:db (update db :accounts/recover assoc
:passphrase (string/lower-case recovery-phrase)
:passphrase-valid? (not (check-phrase-errors recovery-phrase)))}))
(defn validate-phrase [{:keys [db]}]
(let [recovery-phrase (get-in db [:accounts/recover :passphrase])]

View File

@ -28,7 +28,7 @@
:multiline true
:default-value passphrase
:auto-correct false
:on-change-text #(re-frame/dispatch [:recover/set-phrase %])
:on-change-text #(re-frame/dispatch [:recover/set-phrase (security/mask-data %)])
:on-blur #(re-frame/dispatch [:recover/validate-phrase])
:error (cond error (i18n/label error)
warning (i18n/label warning))}]))

View File

@ -44,19 +44,19 @@
(deftest set-phrase
(is (= {:db {:accounts/recover {:passphrase "game buzz method pretty olympic fat quit display velvet unveil marine crater"
:passphrase-valid? true}}}
(models/set-phrase "game buzz method pretty olympic fat quit display velvet unveil marine crater" {:db {}})))
(models/set-phrase (security/mask-data "game buzz method pretty olympic fat quit display velvet unveil marine crater") {:db {}})))
(is (= {:db {:accounts/recover {:passphrase "game buzz method pretty olympic fat quit display velvet unveil marine crater"
:passphrase-valid? true}}}
(models/set-phrase "Game buzz method pretty Olympic fat quit DISPLAY velvet unveil marine crater" {:db {}})))
(models/set-phrase (security/mask-data "Game buzz method pretty Olympic fat quit DISPLAY velvet unveil marine crater") {:db {}})))
(is (= {:db {:accounts/recover {:passphrase "game buzz method pretty zeus fat quit display velvet unveil marine crater"
:passphrase-valid? true}}}
(models/set-phrase "game buzz method pretty zeus fat quit display velvet unveil marine crater" {:db {}})))
(models/set-phrase (security/mask-data "game buzz method pretty zeus fat quit display velvet unveil marine crater") {:db {}})))
(is (= {:db {:accounts/recover {:passphrase " game\t buzz method pretty olympic fat quit\t display velvet unveil marine crater "
:passphrase-valid? true}}}
(models/set-phrase " game\t buzz method pretty olympic fat quit\t display velvet unveil marine crater " {:db {}})))
(models/set-phrase (security/mask-data " game\t buzz method pretty olympic fat quit\t display velvet unveil marine crater ") {:db {}})))
(is (= {:db {:accounts/recover {:passphrase "game buzz method pretty 1234 fat quit display velvet unveil marine crater"
:passphrase-valid? false}}}
(models/set-phrase "game buzz method pretty 1234 fat quit display velvet unveil marine crater" {:db {}}))))
(models/set-phrase (security/mask-data "game buzz method pretty 1234 fat quit display velvet unveil marine crater") {:db {}}))))
(deftest validate-phrase
(is (= {:db {:accounts/recover {:passphrase-error nil