diff options
author | colin <colin@cicadas.surf> | 2023-01-01 08:59:53 -0800 |
---|---|---|
committer | colin <colin@cicadas.surf> | 2023-01-01 08:59:53 -0800 |
commit | 23b40732d41589380d38235e67b27bdd9269b658 (patch) | |
tree | 0373cbf6fba5f7be86ed627c61247dcf0e33165e /home.lisp | |
parent | 58b68da92537f2a48cdb00ee4dd16ea9711c8fb9 (diff) | |
parent | 753f7def0369802f00e29c085f01a391f5b20f07 (diff) |
Merge branch 'featre/password-reset'
Diffstat (limited to 'home.lisp')
-rw-r--r-- | home.lisp | 48 |
1 files changed, 47 insertions, 1 deletions
@@ -84,6 +84,51 @@ (let ((invite (make-invite user (parse-integer (value count) :junk-allowed t)))) (create-invite-list-item invite-list invite))))))) +(defun create-password-reset (parent) + (with-clog-create parent + (div () + (button (:content "Password Reset" :bind pw-reset-toggle)) + (form (:hidden t :bind pw-reset-form) + (form-element (:password :bind pw-input)) + (br ()) + (form-element (:password :bind pw-repeated)) + (br ()) + (button (:content "Change password" :bind pw-update))) + (p (:bind notice-area))) + + (setf (place-holder pw-input) "New Password" + (place-holder pw-repeated) "Repeat New Password" + (disabledp pw-update) t) + + (set-on-key-down + pw-repeated + (thunk* (when (equal (value pw-input) (value pw-repeated)) + (setf (disabledp pw-update) nil)))) + + (flet ((toggle-form () + (cond ((visiblep pw-reset-form) + (setf (visiblep pw-reset-form) nil + (text pw-reset-toggle) "Password Reset" + (text notice-area) "" + (disabledp pw-update) t + (value pw-input) "" + (value pw-repeated) "")) + (t + (setf (visiblep pw-reset-form) t + (text notice-area) "" + (text pw-reset-toggle) "Nevermind"))))) + + (set-on-click pw-update + (thunk* + ;; assumes pw-input and pw-repeat are equal + (set-new-password (session-user parent) (value pw-input)) + (toggle-form) + (setf (text notice-area) + "Password updated!"))) + + (set-on-click pw-reset-toggle + (thunk* (toggle-form)))))) + (defun user-home-page (body) (include-style body) @@ -96,7 +141,8 @@ (section (:h3 :content "Your Playlists")) (div (:class "row") (playlist-listing ())) (new-playlist-form ()) - (invite-control ())))))) + (invite-control ()) + (password-reset ())))))) (defun user-key-from-url (url) (first (last (ppcre:split "/" (nth 4 (multiple-value-list (quri:parse-uri url))))))) |