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 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 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 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
|
### :arrow_up: Deps updates
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
[app.util.router :as rt]
|
[app.util.router :as rt]
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[cljs.spec.alpha :as s]
|
[cljs.spec.alpha :as s]
|
||||||
|
[cuerdas.core :as str]
|
||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]))
|
||||||
|
|
||||||
(mf/defc demo-warning
|
(mf/defc demo-warning
|
||||||
|
@ -45,6 +46,13 @@
|
||||||
(= code ::us/email)
|
(= code ::us/email)
|
||||||
(assoc :message (tr "errors.email-invalid"))))))))
|
(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 ::fullname ::us/not-empty-string)
|
||||||
(s/def ::password ::us/not-empty-string)
|
(s/def ::password ::us/not-empty-string)
|
||||||
(s/def ::email ::us/email)
|
(s/def ::email ::us/email)
|
||||||
|
@ -87,7 +95,7 @@
|
||||||
[{:keys [params on-success-callback] :as props}]
|
[{:keys [params on-success-callback] :as props}]
|
||||||
(let [initial (mf/use-memo (mf/deps params) (constantly params))
|
(let [initial (mf/use-memo (mf/deps params) (constantly params))
|
||||||
form (fm/use-form :spec ::register-form
|
form (fm/use-form :spec ::register-form
|
||||||
:validators [validate]
|
:validators [validate validate-password]
|
||||||
:initial initial)
|
:initial initial)
|
||||||
submitted? (mf/use-state false)
|
submitted? (mf/use-state false)
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
[app.util.dom :as dom]
|
[app.util.dom :as dom]
|
||||||
[app.util.i18n :as i18n :refer [t tr]]
|
[app.util.i18n :as i18n :refer [t tr]]
|
||||||
[cljs.spec.alpha :as s]
|
[cljs.spec.alpha :as s]
|
||||||
|
[cuerdas.core :as str]
|
||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]))
|
||||||
|
|
||||||
(defn- on-error
|
(defn- on-error
|
||||||
|
@ -24,7 +25,7 @@
|
||||||
{:message (tr "errors.wrong-old-password")})
|
{:message (tr "errors.wrong-old-password")})
|
||||||
:email-as-password
|
:email-as-password
|
||||||
(swap! form assoc-in [:errors :password-1]
|
(swap! form assoc-in [:errors :password-1]
|
||||||
{:message (tr "errors.email-as-password")})
|
{:message (tr "errors.email-as-password")})
|
||||||
|
|
||||||
(let [msg (tr "generic.error")]
|
(let [msg (tr "generic.error")]
|
||||||
(st/emit! (dm/error msg)))))
|
(st/emit! (dm/error msg)))))
|
||||||
|
@ -62,6 +63,17 @@
|
||||||
(and password-1 (> 8 (count password-1)))
|
(and password-1 (> 8 (count password-1)))
|
||||||
(assoc :password-1 {:message (tr "errors.password-too-short")}))))
|
(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/def ::password-form
|
||||||
(s/keys :req-un [::password-1
|
(s/keys :req-un [::password-1
|
||||||
::password-2
|
::password-2
|
||||||
|
@ -71,8 +83,8 @@
|
||||||
[{:keys [locale] :as props}]
|
[{:keys [locale] :as props}]
|
||||||
(let [initial (mf/use-memo (constantly {:password-old nil}))
|
(let [initial (mf/use-memo (constantly {:password-old nil}))
|
||||||
form (fm/use-form :spec ::password-form
|
form (fm/use-form :spec ::password-form
|
||||||
:validators [password-equality]
|
:validators [validate-password password-equality]
|
||||||
:initial initial)]
|
:initial initial)]
|
||||||
[:& fm/form {:class "password-form"
|
[:& fm/form {:class "password-form"
|
||||||
:on-submit on-submit
|
:on-submit on-submit
|
||||||
:form form}
|
:form form}
|
||||||
|
@ -105,7 +117,7 @@
|
||||||
(mf/defc password-page
|
(mf/defc password-page
|
||||||
[{:keys [locale]}]
|
[{:keys [locale]}]
|
||||||
(mf/use-effect
|
(mf/use-effect
|
||||||
#(dom/set-html-title (tr "title.settings.password")))
|
#(dom/set-html-title (tr "title.settings.password")))
|
||||||
|
|
||||||
[:section.dashboard-settings.form-container
|
[:section.dashboard-settings.form-container
|
||||||
[:div.form-container
|
[:div.form-container
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue