aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorColin Okay <colin@cicadas.surf>2022-10-31 07:02:21 -0500
committerColin Okay <colin@cicadas.surf>2022-10-31 07:02:21 -0500
commit202f3e1cabb5b8e7e8812d418d53dbeac32c4d1a (patch)
tree586a918ea7de9ea2880d2b8f263ac039128c30e3
parent9416cf44e2e687566e16d76c763e6869a610b925 (diff)
Better name validation
-rw-r--r--new-account.lisp52
1 files changed, 33 insertions, 19 deletions
diff --git a/new-account.lisp b/new-account.lisp
index ea265a7..653818a 100644
--- a/new-account.lisp
+++ b/new-account.lisp
@@ -2,24 +2,31 @@
(in-package :vampire)
+(defparameter +username-regex+
+ (ppcre:create-scanner "^[a-zA-Z0-9\_\\-!@#$^&*]{3,25}$"))
+
+
+
(defun new-accout-page (body)
(include-style 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))))
+ (div (:class "row")
+ (div () (section (:h2 :content "Create a new account"))
+ (form (:bind new-user-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))))
+ (div (:bind name-help :hidden t)
+ (p (:content "3-25 characters, no spaces, numbers, letters, or !@#$^&*()_-"))))
(setf (place-holder invite) "Invite Code"
(place-holder name) "Name"
@@ -36,10 +43,18 @@
(set-on-blur
name
(thunk*
+ (let ((name (value name)))
(setf (text name-status)
- (if (user-with-name name)
- "Name Already Taken"
- "✔"))))
+ (cond
+ ((not (ppcre:all-matches +username-regex+ name))
+ (setf (visiblep name-help) t)
+ "Invalid Name.")
+ ((user-with-name name)
+ (setf (visiblep name-help) nil)
+ "Name Already Taken")
+ (t
+ (setf (visiblep name-help) nil)
+ "✔"))))))
(set-on-key-press
pw-confirm
@@ -49,7 +64,6 @@
"✔"
"Passwords Do Not Match"))))
-
(set-on-click
submit
(thunk*