From 6f729e2d0e44252460e5b287776f7ad82ed8da06 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Thu, 27 Oct 2022 10:23:32 -0500 Subject: Add: new-account stuff --- new-account.lisp | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ vampire.asd | 1 + vampire.lisp | 1 + 3 files changed, 65 insertions(+) create mode 100644 new-account.lisp diff --git a/new-account.lisp b/new-account.lisp new file mode 100644 index 0000000..10311af --- /dev/null +++ b/new-account.lisp @@ -0,0 +1,63 @@ +;;;; new-account.lisp + +(in-package :vampire) + +(defun valid-invite-code-p (arg) arg) +(defun use-invite-with-code (code username pw)) + +(defun new-accout-page (body) + (with-clog-create body + (div () + (section (:h2 :content "Create a new account")) + (form () + (form-element (:text :bind invite)) + (span (:bind invite-status)) + (br ()) + (form-element (:text :bind name)) + (span (:bind name-status)) + (br ()) + (form-element (:password :bind pw)) + (br ()) + (form-element (:password :bind pw-confirm)) + (span (:bind pw-confirm-status)) + (br ()) + (button (:content "Make Account" :bind submit)))) + + (setf (place-holder invite) "Invite Code" + (place-holder name) "Name" + (place-holder pw) "Password" + (place-holder pw-confirm) "Repeat Password") + + (set-on-blur + invite + (thunk* + (setf (inner-html invite-status) + (if (valid-invite-code-p (value invite)) + "✔" + "Bad Invite Code")))) + (set-on-blur + name + (thunk* + (setf (text name-status) + (if (user-with-name name) + "Name Already Taken" + "✔")))) + + (set-on-key-press + pw-confirm + (thunk* + (setf (text pw-confirm-status) + (if (string-equal (value pw) (value pw-confirm)) + "✔" + "Passwords Do Not Match")))) + + + (set-on-click + submit + (thunk* + (if (loop for status in (list pw-confirm-status name-status invite-status) + always (string-equal "✔" (value status))) + (if (use-invite-with-code (value invite) (value name) (value pw)) + (setf (url (location body)) "/login") + (alert (window body) "An error occurred while making your account.")) + (alert (window body) "Plase double check your inputs.")))))) diff --git a/vampire.asd b/vampire.asd index 87e187f..dbde6f1 100644 --- a/vampire.asd +++ b/vampire.asd @@ -19,6 +19,7 @@ (:file "downloader") (:file "model") (:file "session") + (:file "new-account") (:file "login") (:file "user") (:file "playlist") diff --git a/vampire.lisp b/vampire.lisp index e4940f9..97266d3 100644 --- a/vampire.lisp +++ b/vampire.lisp @@ -94,6 +94,7 @@ (set-on-new-window 'user-home-page :path "/home") (set-on-new-window 'login-page :path "/login") (set-on-new-window 'playlist-page :path "/playlist") + (set-on-new-window 'new-accout-page :path "/new-account") (open-browser)) (defun hacking-start () -- cgit v1.2.3