summaryrefslogtreecommitdiff
path: root/site/invites.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'site/invites.lisp')
-rw-r--r--site/invites.lisp42
1 files changed, 40 insertions, 2 deletions
diff --git a/site/invites.lisp b/site/invites.lisp
index b463a4d..dc1f31c 100644
--- a/site/invites.lisp
+++ b/site/invites.lisp
@@ -9,6 +9,44 @@
(make-instance 'invite :maker user :uses-remaining 1))
(wknd:endpoint-redirect 'home.html)))
-(defun invite-validp (invite)
+(defun invite-valid-p (invite)
(let ((uses (uses-remaining invite)))
- (or (< 0 uses) (null uses))))
+ (or (plusp uses) (null uses))))
+
+
+(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 (invite-validp invite)
+ :handle (progn
+ (db:with-transaction ()
+ (when (uses-remaining invite)
+ (decf (uses-remaining invite))
+ (when (zerop (uses-remaining invite))
+ (db:delete-object invite)))
+ (let ((user (make-instance 'user :name username)))
+ (setf (user-pwhash user) (hash-string password (user-pwsalt user)))))
+ (wknd:endpoint-redirect 'login.html)))
+
+(wknd:defendpoint new-account.html
+ :get :route "new-account"
+ :returns "text/html"
+ :handle (new-account-page))
+
+(defun new-account-page ()
+ (page (:title "V A M P I R E ~ JOIN")
+ (:form :method "POST" :action (wknd:route-to 'create-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"))))