aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2009-02-20 22:19:54 +0100
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2009-02-20 22:19:54 +0100
commit6ec04ffff7bd50a80ca54b79217a3d0fdd61f34c (patch)
treea22ec799bc64db13f6e2483c34d23f7ecdb29920
parentfd47a96c0bb0484a7ba8387596d62613883f8651 (diff)
Add beginnings of log-in handling.
-rw-r--r--cljssss-g.clj24
1 files changed, 20 insertions, 4 deletions
diff --git a/cljssss-g.clj b/cljssss-g.clj
index e79afa6..3215bbb 100644
--- a/cljssss-g.clj
+++ b/cljssss-g.clj
@@ -14,10 +14,26 @@
(defservlet cljssss-g
(GET "/"
- (.toString
- (doto (.getInstanceOf templates "index")
- (.setAttributes {"title" "Subscriptions",
- "mainParagraph" "Hi there!"}))))
+ (if (@session :id)
+ (.toString
+ (doto (.getInstanceOf templates "index")
+ (.setAttributes {"title" "Subscriptions",
+ "mainParagraph" "Hi there!"})))
+ (redirect-to "/login")))
+ (GET "/login"
+ ;; FIXME
+ )
+ (POST "/login"
+ (dosync
+ (with-db
+ (sql/with-query-results [{id :id password :password}]
+ ["SELECT id, password FROM user WHERE name = ?"
+ (@params :name)]
+ (if (= password (@params :password))
+ (do
+ (alter session assoc :id id)
+ (redirect-to "/"))
+ (redirect-to "/login"))))))
(ANY "*"
(page-not-found)))