mirror of
https://github.com/penpot/penpot.git
synced 2025-05-19 23:36:11 +02:00
Allow to change password (#6)
This commit is contained in:
parent
cb524ee814
commit
78987419d2
3 changed files with 24 additions and 14 deletions
|
@ -61,18 +61,15 @@
|
||||||
|
|
||||||
;; --- Update Password
|
;; --- Update Password
|
||||||
|
|
||||||
(defrecord UpdatePassword [password]
|
(defrecord UpdatePassword [old-password password]
|
||||||
rs/WatchEvent
|
rs/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(-apply-watch [_ state s]
|
||||||
;; (letfn [(on-error [err]
|
(letfn [(on-error [err]
|
||||||
;; (uum/error (tr "errors.update-password"))
|
(uum/error (tr "errors.update-password"))
|
||||||
;; (rx/empty))]
|
(rx/empty))]
|
||||||
;; (->> (rp/req :update/password data)
|
(->> (rp/req :update/password {:old-password old-password :password password})
|
||||||
;; (rx/catch on-error)))))
|
(rx/catch on-error)))))
|
||||||
(js/alert "Not implemented")
|
|
||||||
(rx/empty)))
|
|
||||||
|
|
||||||
(defn update-password
|
(defn update-password
|
||||||
[password]
|
[old-password password]
|
||||||
{:pre [(string? password)]}
|
(UpdatePassword. old-password password))
|
||||||
(UpdatePassword. password))
|
|
||||||
|
|
|
@ -22,3 +22,10 @@
|
||||||
:method :put
|
:method :put
|
||||||
:body data}]
|
:body data}]
|
||||||
(send! params)))
|
(send! params)))
|
||||||
|
|
||||||
|
(defmethod request :update/password
|
||||||
|
[type data]
|
||||||
|
(let [params {:url (str url "/profile/me/password")
|
||||||
|
:method :put
|
||||||
|
:body data}]
|
||||||
|
(send! params)))
|
||||||
|
|
|
@ -32,13 +32,18 @@
|
||||||
(let [value (dom/event->value event)]
|
(let [value (dom/event->value event)]
|
||||||
(swap! local assoc field value)))
|
(swap! local assoc field value)))
|
||||||
(on-submit [event]
|
(on-submit [event]
|
||||||
(let [password (:password-1 @local)]
|
(let [password (:password-1 @local)
|
||||||
(rs/emit! (udu/update-password password))))]
|
old-password (:old-password @local)]
|
||||||
|
(rs/emit! (udu/update-password old-password password))))]
|
||||||
|
|
||||||
(html
|
(html
|
||||||
[:form.password-form
|
[:form.password-form
|
||||||
[:span.user-settings-label "Change password"]
|
[:span.user-settings-label "Change password"]
|
||||||
#_[:input.input-text {:type "password" :placeholder "Old password"}]
|
[:input.input-text
|
||||||
|
{:type "password"
|
||||||
|
:value (:old-password @local "")
|
||||||
|
:on-change (partial on-field-change :old-password)
|
||||||
|
:placeholder "Old password"}]
|
||||||
[:input.input-text
|
[:input.input-text
|
||||||
{:type "password"
|
{:type "password"
|
||||||
:value (:password-1 @local "")
|
:value (:password-1 @local "")
|
||||||
|
@ -53,6 +58,7 @@
|
||||||
{:type "button"
|
{:type "button"
|
||||||
:class (when-not valid? "btn-disabled")
|
:class (when-not valid? "btn-disabled")
|
||||||
:disabled (not valid?)
|
:disabled (not valid?)
|
||||||
|
:on-click on-submit
|
||||||
:value "Update settings"}]]))))
|
:value "Update settings"}]]))))
|
||||||
|
|
||||||
(def password-form
|
(def password-form
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue