0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-13 16:21:57 -05:00

Allow to change password (#6)

This commit is contained in:
Jesús Espino 2016-04-10 17:48:56 +02:00 committed by Andrey Antukh
parent cb524ee814
commit 78987419d2
3 changed files with 24 additions and 14 deletions

View file

@ -61,18 +61,15 @@
;; --- Update Password
(defrecord UpdatePassword [password]
(defrecord UpdatePassword [old-password password]
rs/WatchEvent
(-apply-watch [_ state s]
;; (letfn [(on-error [err]
;; (uum/error (tr "errors.update-password"))
;; (rx/empty))]
;; (->> (rp/req :update/password data)
;; (rx/catch on-error)))))
(js/alert "Not implemented")
(rx/empty)))
(letfn [(on-error [err]
(uum/error (tr "errors.update-password"))
(rx/empty))]
(->> (rp/req :update/password {:old-password old-password :password password})
(rx/catch on-error)))))
(defn update-password
[password]
{:pre [(string? password)]}
(UpdatePassword. password))
[old-password password]
(UpdatePassword. old-password password))

View file

@ -22,3 +22,10 @@
:method :put
:body data}]
(send! params)))
(defmethod request :update/password
[type data]
(let [params {:url (str url "/profile/me/password")
:method :put
:body data}]
(send! params)))

View file

@ -32,13 +32,18 @@
(let [value (dom/event->value event)]
(swap! local assoc field value)))
(on-submit [event]
(let [password (:password-1 @local)]
(rs/emit! (udu/update-password password))))]
(let [password (:password-1 @local)
old-password (:old-password @local)]
(rs/emit! (udu/update-password old-password password))))]
(html
[:form.password-form
[: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
{:type "password"
:value (:password-1 @local "")
@ -53,6 +58,7 @@
{:type "button"
:class (when-not valid? "btn-disabled")
:disabled (not valid?)
:on-click on-submit
:value "Update settings"}]]))))
(def password-form