diff options
author | colin <colin@cicadas.surf> | 2024-05-31 10:06:47 -0700 |
---|---|---|
committer | colin <colin@cicadas.surf> | 2024-05-31 10:06:47 -0700 |
commit | 2832a7c9e75400e36ca12a028ffcbeece44c8216 (patch) | |
tree | c4ad4cc7a63c3c2e54da0ab4bd41bfc6c7edf8ad | |
parent | e12561b1f2c541b579065c5b40c74957fdab866c (diff) |
checkpoint
-rw-r--r-- | package.lisp | 1 | ||||
-rw-r--r-- | session.lisp | 4 | ||||
-rw-r--r-- | site/home.lisp | 22 | ||||
-rw-r--r-- | site/login.lisp | 10 | ||||
-rw-r--r-- | vampire.asd | 3 |
5 files changed, 37 insertions, 3 deletions
diff --git a/package.lisp b/package.lisp index 0335b3d..e88297e 100644 --- a/package.lisp +++ b/package.lisp @@ -7,6 +7,7 @@ (#:wknd #:weekend) (#:a #:alexandria-2) (#:zippy #:org.shirakumo.zippy )) + (:import-from #:flatbind #:do>) (:import-from #:bknr.datastore #:with-transaction #:store-object diff --git a/session.lisp b/session.lisp index 6d704f7..77a3bfe 100644 --- a/session.lisp +++ b/session.lisp @@ -13,7 +13,7 @@ ;;; SESSION PARAMETER KEYS -(defparameter +session-key+ "vampire-session-key" - "Stored in the browser's local storage") +(defparameter +session-cookie+ "session" + "Cookie name") diff --git a/site/home.lisp b/site/home.lisp new file mode 100644 index 0000000..97c2a87 --- /dev/null +++ b/site/home.lisp @@ -0,0 +1,22 @@ +(in-package #:vampire) + +(defclass user-known () + ((user :accessor user))) + +(defmethod wknd:authenticate ((req user-known)) + (or + (do> + key :when= (wknd:get-cookie +session-cookie+) + session :when= (object-with-key key) + :when (typep session 'session) + (setf (user req) (user session))) + (weekend:endpoint-redirect 'login))) + +(defun home-page (user) + (format nil "hey ~a" (user-name user))) + +(wknd:defendpoint home + :using user-known + :get :route "" + :returns "text/html" + :handle (home-page user)) diff --git a/site/login.lisp b/site/login.lisp new file mode 100644 index 0000000..afbd80e --- /dev/null +++ b/site/login.lisp @@ -0,0 +1,10 @@ +(in-package #:vampire) + +(defun login-page () + "login") + +(wknd:defendpoint login + :get :route "login" + :returns "text/html" + :handle (login-page)) + diff --git a/vampire.asd b/vampire.asd index 10c0453..c618e3b 100644 --- a/vampire.asd +++ b/vampire.asd @@ -15,7 +15,8 @@ #:ironclad #:jonathan #:swank - #:zippy) + #:zippy + #:flatbind) :components (;(:file "hunchentoot-handle-static-file") (:file "package") (:file "definition-macros") |