diff --git a/CHANGES.md b/CHANGES.md index 111d5b9a5..634fd470e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -52,6 +52,7 @@ - Forbid empty names for assets [Taiga #5056](https://tree.taiga.io/project/penpot/issue/5056) - Select children after ungroup action [Taiga #4917](https://tree.taiga.io/project/penpot/issue/4917) - Fix problem with guides not showing when moving over nested frames [Taiga #4905](https://tree.taiga.io/project/penpot/issue/4905) +- Fix change email and password for users signed in via social login [Taiga #4273](https://tree.taiga.io/project/penpot/issue/4273) ### :heart: Community contributions by (Thank you!) - To @ondrejkonec: for contributing to the code with: diff --git a/backend/src/app/rpc/commands/profile.clj b/backend/src/app/rpc/commands/profile.clj index acdb2584b..71751a382 100644 --- a/backend/src/app/rpc/commands/profile.clj +++ b/backend/src/app/rpc/commands/profile.clj @@ -113,7 +113,7 @@ (declare invalidate-profile-session!) (s/def ::password ::us/not-empty-string) -(s/def ::old-password ::us/not-empty-string) +(s/def ::old-password (s/nilable ::us/string)) (s/def ::update-profile-password (s/keys :req [::rpc/profile-id] @@ -145,7 +145,8 @@ (defn- validate-password! [conn {:keys [profile-id old-password] :as params}] (let [profile (db/get-by-id conn :profile profile-id ::db/for-update? true)] - (when-not (:valid (auth/verify-password old-password (:password profile))) + (when (and (not= (:password profile) "!") + (not (:valid (auth/verify-password old-password (:password profile))))) (ex/raise :type :validation :code :old-password-not-match)) profile)) diff --git a/backend/src/app/rpc/mutations/profile.clj b/backend/src/app/rpc/mutations/profile.clj index 406e029cb..89b59083a 100644 --- a/backend/src/app/rpc/mutations/profile.clj +++ b/backend/src/app/rpc/mutations/profile.clj @@ -32,7 +32,7 @@ (s/def ::path ::us/string) (s/def ::profile-id ::us/uuid) (s/def ::password ::us/not-empty-string) -(s/def ::old-password ::us/not-empty-string) +(s/def ::old-password (s/nilable ::us/string)) (s/def ::theme ::us/string) ;; --- MUTATION: Update Profile (own) diff --git a/frontend/src/app/main/data/users.cljs b/frontend/src/app/main/data/users.cljs index 5cf2932ab..676e5cec0 100644 --- a/frontend/src/app/main/data/users.cljs +++ b/frontend/src/app/main/data/users.cljs @@ -38,7 +38,7 @@ (s/def ::created-at ::us/inst) (s/def ::password-1 ::us/string) (s/def ::password-2 ::us/string) -(s/def ::password-old ::us/string) +(s/def ::password-old (s/nilable ::us/string)) (s/def ::profile (s/keys :req-un [::id] diff --git a/frontend/src/app/main/ui/settings/password.cljs b/frontend/src/app/main/ui/settings/password.cljs index 940e4fd8f..9e792d545 100644 --- a/frontend/src/app/main/ui/settings/password.cljs +++ b/frontend/src/app/main/ui/settings/password.cljs @@ -32,7 +32,10 @@ (defn- on-success [form] (reset! form nil) - (let [msg (tr "dashboard.notifications.password-saved")] + (let [password-old-node (dom/get-element "password-old") + msg (tr "dashboard.notifications.password-saved")] + (dom/clean-value! password-old-node) + (dom/focus! password-old-node) (st/emit! (dm/success msg)))) (defn- on-submit @@ -45,7 +48,7 @@ (s/def ::password-1 ::us/not-empty-string) (s/def ::password-2 ::us/not-empty-string) -(s/def ::password-old ::us/not-empty-string) +(s/def ::password-old (s/nilable ::us/string)) (defn- password-equality [errors data] @@ -66,9 +69,10 @@ (mf/defc password-form [{:keys [locale] :as props}] - (let [form (fm/use-form :spec ::password-form - :validators [password-equality] - :initial {})] + (let [initial (mf/use-memo (constantly {:password-old nil})) + form (fm/use-form :spec ::password-form + :validators [password-equality] + :initial initial)] [:& fm/form {:class "password-form" :on-submit on-submit :form form} @@ -77,6 +81,7 @@ [:& fm/input {:type "password" :name :password-old + :auto-focus? true :label (t locale "labels.old-password")}]] [:div.fields-row