diff --git a/CHANGES.md b/CHANGES.md index a584c9000..d3eefa8cb 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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 diff --git a/frontend/src/app/main/ui/auth/register.cljs b/frontend/src/app/main/ui/auth/register.cljs index 76ce3a1ac..37314093b 100644 --- a/frontend/src/app/main/ui/auth/register.cljs +++ b/frontend/src/app/main/ui/auth/register.cljs @@ -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) diff --git a/frontend/src/app/main/ui/settings/password.cljs b/frontend/src/app/main/ui/settings/password.cljs index 9e792d545..f9ab2a915 100644 --- a/frontend/src/app/main/ui/settings/password.cljs +++ b/frontend/src/app/main/ui/settings/password.cljs @@ -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