diff options
author | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2009-02-20 22:19:54 +0100 |
---|---|---|
committer | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2009-02-20 22:19:54 +0100 |
commit | 6ec04ffff7bd50a80ca54b79217a3d0fdd61f34c (patch) | |
tree | a22ec799bc64db13f6e2483c34d23f7ecdb29920 | |
parent | fd47a96c0bb0484a7ba8387596d62613883f8651 (diff) |
Add beginnings of log-in handling.
-rw-r--r-- | cljssss-g.clj | 24 |
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))) |