Skip to content

Commit

Permalink
Update password to be at least 8 characters
Browse files Browse the repository at this point in the history
Add description that emojis are supported.

Update minimum password length for reset password popup

add password utility

Update onboarding and reset password views to share password checking code
  • Loading branch information
dangarbri committed Mar 6, 2022
1 parent cf606b9 commit 318cd9e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/status_im/constants.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
(def ^:const profile-pictures-visibility-everyone 2)
(def ^:const profile-pictures-visibility-none 3)

(def ^:const min-password-length 6)
(def ^:const min-password-length 8)
(def ^:const max-group-chat-participants 20)
(def ^:const default-number-of-messages 20)
(def ^:const default-number-of-pin-messages 3)
Expand Down
5 changes: 3 additions & 2 deletions src/status_im/subs.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
[status-im.utils.gfycat.core :as gfycat]
[status-im.utils.money :as money]
[status-im.utils.security :as security]
[status-im.utils.password-resources :as pass]
[status-im.wallet.db :as wallet.db]
[status-im.wallet.utils :as wallet.utils]
status-im.ui.screens.keycard.subs
Expand Down Expand Up @@ -2938,9 +2939,9 @@
(and (pos? (count current-password))
(pos? (count new-password))
(pos? (count confirm-new-password))
(>= (count new-password) 6)
(pass/valid-password new-password)
(>= (count current-password) 6)
(= new-password confirm-new-password))})))
(pass/confirm-password new-password confirm-new-password))})))

(re-frame/reg-sub
:bookmarks/active
Expand Down
13 changes: 4 additions & 9 deletions src/status_im/ui/screens/onboarding/password/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,19 @@
[status-im.i18n.i18n :as i18n]
[status-im.constants :as const]
[status-im.utils.security :as security]
[status-im.utils.password-resources :as pass]
[quo.react-native :as rn]
[quo.core :as quo]))

(defn validate-password [password]
(>= (count password) const/min-password-length))

(defn confirm-password [password confirm]
(= password confirm))

(defn screen []
(let [password (reagent/atom nil)
confirm (reagent/atom nil)
processing? (reagent/atom nil)
show-error (reagent/atom nil)
confirm-ref (atom nil)]
(fn []
(let [valid-password (validate-password @password)
valid-form (confirm-password @password @confirm)
(let [valid-password (pass/validate-password @password)
valid-form (pass/confirm-password @password @confirm)
{:keys [recovering?]} @(re-frame/subscribe [:intro-wizard])
on-submit (fn []
(when (not @processing?)
Expand Down Expand Up @@ -74,7 +69,7 @@
(> (count @password) (count @confirm))
(reset! show-error false)

(not (confirm-password @password @confirm))
(not (pass/confirm-password @password @confirm))
(reset! show-error true)

:else (reset! show-error false)))}]]]
Expand Down
25 changes: 25 additions & 0 deletions src/status_im/utils/password_utils.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
(ns status-im.utils.password-resources
(:require [status-im.constants :as const]))

(defn to-numbers [vals]
(map int vals))

(defn diff [vals]
(map - (next vals) vals))

(defn is-same? [a b]
(= a b))

(defn all-same? [word]
(let [first-letter (first word)]
(every? #{first-letter} word)))

(defn is-sequential? [sequence]
(all-same? (diff (to-numbers sequence))))

(defn validate-password [password]
(and (>= (count password) const/min-password-length)
(not (all-same? password))))

(defn confirm-password [password confirm]
(= password confirm))
2 changes: 1 addition & 1 deletion translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@
"pairing-please-set-a-name": "Please set a name for your device.",
"passphrase": "Passphrase",
"password": "Password",
"password-description": "At least 6 characters. Your password protects your keys. You need it to unlock Status and transact.",
"password-description": "At least 8 characters. It may also include unicode characters and emojis. Your password protects your keys. You need it to unlock Status and transact.",
"password-placeholder2": "Confirm your password",
"password_error1": "Passwords don't match.",
"paste": "Paste",
Expand Down

0 comments on commit 318cd9e

Please sign in to comment.