summaryrefslogtreecommitdiff
path: root/site
diff options
context:
space:
mode:
authorGrant Shangreaux <grant@unabridgedsoftware.com>2024-05-31 15:36:21 -0500
committerGrant Shangreaux <grant@unabridgedsoftware.com>2024-05-31 15:36:21 -0500
commita98270e2f8d90a9026394aff0aaa104824f045fa (patch)
treecd5bbff817548dec5c9b186c4ef6bbbdada535b2 /site
parent9b51a908448c23eff673934f023d247a6c47519d (diff)
Add: new user page
Diffstat (limited to 'site')
-rw-r--r--site/login.lisp58
1 files changed, 47 insertions, 11 deletions
diff --git a/site/login.lisp b/site/login.lisp
index 66d20ff..14852c3 100644
--- a/site/login.lisp
+++ b/site/login.lisp
@@ -1,16 +1,5 @@
(in-package #:vampire)
-(defun login-page ()
- (with-html-string
- (:div (:h1 "I vant to suck your blood")
- (:form :method "POST" :action "/login"
- (:input :placeholder "Name" :name "name")
- (:br)
- (:input :placeholder "Password" :type "password" :name "password")
- (:br)
- (:button :type "submit" "Click to Login")))
- (:a :href "/new-account" "Come to the Dark Side")))
-
(wknd:defendpoint login
:get :route "login"
:returns "text/html"
@@ -34,3 +23,50 @@
session := (db:with-transaction () (make-instance 'session :user found-user))
(wknd:set-cookie +session-cookie+ :value (key session))))
+(wknd:defendpoint new-account-page
+ :get :route "new-account"
+ :returns "text/html"
+ :handle (new-account-page))
+
+(wknd:defendpoint create-new-account
+ :post :to "new-account"
+ :parameters
+ (username string)
+ (password string)
+ (password2 string)
+ (invite-code string)
+ :properties
+ (invite invite)
+ :authenticate (and
+ (equal password password2)
+ (setf invite (object-with-key invite-code)))
+ :authorize (or (null (uses-remaining invite)) (plusp (uses-remaining invite)))
+ :handle (progn
+ (db:with-transaction ()
+ (when (uses-remaining invite)
+ (decf (uses-remaining invite)))
+ (let ((user (make-instance 'user :name username)))
+ (setf (user-pwhash user) (hash-string password (user-pwsalt user)))))
+ (wknd:endpoint-redirect 'login)))
+
+(defun login-page ()
+ (with-html-string
+ (:div (:h1 "I vant to suck your blood")
+ (:form :method "POST" :action "/login"
+ (:input :placeholder "Name" :name "name")
+ (:br)
+ (:input :placeholder "Password" :type "password" :name "password")
+ (:br)
+ (:button :type "submit" "Click to Login")))
+ (:a :href "/new-account" "Come to the Dark Side")))
+
+(defun new-account-page ()
+ (with-html-string
+ (:form :method "POST" :action "/new-account"
+ (:input :placeholder "Invite Code" :name "invite-code")(:br)
+ (:input :placeholder "Username" :name "username")(:br)
+ (:input :placeholder "Password" :name "password" :type "password")(:br)
+ (:input :placeholder "Repeat Password" :name "password2" :type "password")(:br)
+ (:button :type "submit" "Become Undead"))))
+
+