summaryrefslogtreecommitdiff
path: root/home.lisp
diff options
context:
space:
mode:
authorcolin <colin@cicadas.surf>2023-01-01 08:48:50 -0800
committercolin <colin@cicadas.surf>2023-01-01 08:48:50 -0800
commit7a3b904c26e2a08a88f58684d03aff3fb2a39c86 (patch)
treee25e9f241715ec9003f10f8b2e704264e87bbf80 /home.lisp
parentc0ff3d5317e2a70329fde1b56b52dfa203f9c445 (diff)
Add: password reset feature
Diffstat (limited to 'home.lisp')
-rw-r--r--home.lisp48
1 files changed, 47 insertions, 1 deletions
diff --git a/home.lisp b/home.lisp
index 4e4135a..cac1c3b 100644
--- a/home.lisp
+++ b/home.lisp
@@ -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)))))))