0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-26 08:29:42 -05:00

🐛 Fix error handling on register page

This commit is contained in:
Andrey Antukh 2024-03-06 09:17:04 +01:00
parent 8cb550120a
commit 5b722a8608

View file

@ -58,33 +58,33 @@
:opt-un [::invitation-token])) :opt-un [::invitation-token]))
(defn- handle-prepare-register-error (defn- handle-prepare-register-error
[form {:keys [type code] :as cause}] [form cause]
(condp = [type code] (let [{:keys [type code]} (ex-data cause)]
[:restriction :registration-disabled] (condp = [type code]
(st/emit! (msg/error (tr "errors.registration-disabled"))) [:restriction :registration-disabled]
(st/emit! (msg/error (tr "errors.registration-disabled")))
[:restriction :profile-blocked] [:restriction :profile-blocked]
(st/emit! (msg/error (tr "errors.profile-blocked"))) (st/emit! (msg/error (tr "errors.profile-blocked")))
[:validation :email-has-permanent-bounces] [:validation :email-has-permanent-bounces]
(let [email (get @form [:data :email])] (let [email (get @form [:data :email])]
(st/emit! (msg/error (tr "errors.email-has-permanent-bounces" email)))) (st/emit! (msg/error (tr "errors.email-has-permanent-bounces" email))))
[:validation :email-already-exists] [:validation :email-already-exists]
(swap! form assoc-in [:errors :email] (swap! form assoc-in [:errors :email]
{:message "errors.email-already-exists"}) {:message "errors.email-already-exists"})
[:validation :email-as-password] [:validation :email-as-password]
(swap! form assoc-in [:errors :password] (swap! form assoc-in [:errors :password]
{:message "errors.email-as-password"}) {:message "errors.email-as-password"})
(st/emit! (msg/error (tr "errors.generic"))))) (st/emit! (msg/error (tr "errors.generic"))))))
(defn- handle-prepare-register-success (defn- handle-prepare-register-success
[params] [params]
(st/emit! (rt/nav :auth-register-validate {} params))) (st/emit! (rt/nav :auth-register-validate {} params)))
(mf/defc register-form (mf/defc register-form
[{: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))