aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--package.lisp1
-rw-r--r--session.lisp4
-rw-r--r--site/home.lisp22
-rw-r--r--site/login.lisp10
-rw-r--r--vampire.asd3
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")