mirror of
https://github.com/penpot/penpot.git
synced 2025-01-22 14:39:45 -05: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
|
||||
|
@ -24,7 +25,7 @@
|
|||
{:message (tr "errors.wrong-old-password")})
|
||||
:email-as-password
|
||||
(swap! form assoc-in [:errors :password-1]
|
||||
{:message (tr "errors.email-as-password")})
|
||||
{:message (tr "errors.email-as-password")})
|
||||
|
||||
(let [msg (tr "generic.error")]
|
||||
(st/emit! (dm/error msg)))))
|
||||
|
@ -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,8 +83,8 @@
|
|||
[{:keys [locale] :as props}]
|
||||
(let [initial (mf/use-memo (constantly {:password-old nil}))
|
||||
form (fm/use-form :spec ::password-form
|
||||
:validators [password-equality]
|
||||
:initial initial)]
|
||||
:validators [validate-password password-equality]
|
||||
:initial initial)]
|
||||
[:& fm/form {:class "password-form"
|
||||
:on-submit on-submit
|
||||
:form form}
|
||||
|
@ -105,7 +117,7 @@
|
|||
(mf/defc password-page
|
||||
[{:keys [locale]}]
|
||||
(mf/use-effect
|
||||
#(dom/set-html-title (tr "title.settings.password")))
|
||||
#(dom/set-html-title (tr "title.settings.password")))
|
||||
|
||||
[:section.dashboard-settings.form-container
|
||||
[:div.form-container
|
||||
|
|
Loading…
Add table
Reference in a new issue