mirror of
https://github.com/penpot/penpot.git
synced 2025-08-07 14:38:33 +02:00
🐛 Fix create and account only with spaces
This commit is contained in:
parent
e75b53ff8d
commit
82183ec71a
3 changed files with 26 additions and 6 deletions
|
@ -28,7 +28,7 @@
|
|||
- Fix drag projects on dahsboard [Taiga #5531](https://tree.taiga.io/project/penpot/issue/5531)
|
||||
- Fix allow team name to be all blank [Taiga #5527](https://tree.taiga.io/project/penpot/issue/5527)
|
||||
- Fix search font visualitation [Taiga #5523](https://tree.taiga.io/project/penpot/issue/5523)
|
||||
|
||||
- Fix create and account only with spaces [Taiga #5518](https://tree.taiga.io/project/penpot/issue/5518)
|
||||
|
||||
### :arrow_up: Deps updates
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
[app.util.router :as rt]
|
||||
[beicon.core :as rx]
|
||||
[cljs.spec.alpha :as s]
|
||||
[cuerdas.core :as str]
|
||||
[rumext.v2 :as mf]))
|
||||
|
||||
(mf/defc demo-warning
|
||||
|
@ -45,6 +46,13 @@
|
|||
(= code ::us/email)
|
||||
(assoc :message (tr "errors.email-invalid"))))))))
|
||||
|
||||
(defn- validate-password
|
||||
[errors data]
|
||||
(let [password (-> data :password str/trim)]
|
||||
(cond-> errors
|
||||
(str/empty? password)
|
||||
(assoc :password {:message (tr "auth.password-not-empty")}))))
|
||||
|
||||
(s/def ::fullname ::us/not-empty-string)
|
||||
(s/def ::password ::us/not-empty-string)
|
||||
(s/def ::email ::us/email)
|
||||
|
@ -87,7 +95,7 @@
|
|||
[{:keys [params on-success-callback] :as props}]
|
||||
(let [initial (mf/use-memo (mf/deps params) (constantly params))
|
||||
form (fm/use-form :spec ::register-form
|
||||
:validators [validate]
|
||||
:validators [validate validate-password]
|
||||
:initial initial)
|
||||
submitted? (mf/use-state false)
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
[app.util.dom :as dom]
|
||||
[app.util.i18n :as i18n :refer [t tr]]
|
||||
[cljs.spec.alpha :as s]
|
||||
[cuerdas.core :as str]
|
||||
[rumext.v2 :as mf]))
|
||||
|
||||
(defn- on-error
|
||||
|
@ -62,6 +63,17 @@
|
|||
(and password-1 (> 8 (count password-1)))
|
||||
(assoc :password-1 {:message (tr "errors.password-too-short")}))))
|
||||
|
||||
(defn- validate-password
|
||||
[errors data]
|
||||
(let [password-1 (-> data :password-1 str/trim)
|
||||
password-2 (-> data :password-2 str/trim)]
|
||||
(cond-> errors
|
||||
(str/empty? password-1)
|
||||
(assoc :password-1 {:message (tr "auth.password-not-empty")})
|
||||
|
||||
(str/empty? password-2)
|
||||
(assoc :password-2 {:message (tr "auth.password-not-empty")}))))
|
||||
|
||||
(s/def ::password-form
|
||||
(s/keys :req-un [::password-1
|
||||
::password-2
|
||||
|
@ -71,7 +83,7 @@
|
|||
[{:keys [locale] :as props}]
|
||||
(let [initial (mf/use-memo (constantly {:password-old nil}))
|
||||
form (fm/use-form :spec ::password-form
|
||||
:validators [password-equality]
|
||||
:validators [validate-password password-equality]
|
||||
:initial initial)]
|
||||
[:& fm/form {:class "password-form"
|
||||
:on-submit on-submit
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue