From eb9939d459cc177f87e0f2ca25d8ff415bed8c59 Mon Sep 17 00:00:00 2001 From: christoph Date: Fri, 20 Feb 2009 22:30:20 +0100 Subject: Funktionen zum Login, Loginseite erstellt --- cljssss-g.clj | 38 +++++++++++++++++++++++++++----------- login.st | 18 ++++++++++++++++++ 2 files changed, 45 insertions(+), 11 deletions(-) create mode 100644 login.st diff --git a/cljssss-g.clj b/cljssss-g.clj index e79afa6..0588a59 100644 --- a/cljssss-g.clj +++ b/cljssss-g.clj @@ -12,8 +12,32 @@ (def templates (new StringTemplateGroup "")) + +(defn login-view [] + (.toString (.getInstanceOf templates "login"))) + + (defservlet cljssss-g - (GET "/" + (GET "/login" + (if (= (params :wrong) "true") + (.toString (doto + (.getInstanceOf templates "login") + (.setAttributes {"logintext" "Login failed"}))) + (.toString (doto + (.getInstanceOf templates "login") + (.setAttributes {"logintext" "Login"}))))) + (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?wrong=true")))))) + (GET "/blah/" (.toString (doto (.getInstanceOf templates "index") (.setAttributes {"title" "Subscriptions", @@ -114,16 +138,8 @@ ;;;; Sample database content (comment - (with-dbt - (sql/update-or-insert-values :feed - ["id = ?" 0] - {:id 0 - :uri "http://matthias.benkard.de/journal/feed/"}) - (sql/update-or-insert-values :feed - ["id = ?" 1] - {:id 1 - :uri "http://uxul.wordpress.com/feed/"}))) - + (subscribe-to-feed "http://matthias.benkard.de/journal/feed/") + (subscribe-to-feed "http://uxul.wordpress.com/feed/")) ;;;; Database schema (comment diff --git a/login.st b/login.st new file mode 100644 index 0000000..3583b88 --- /dev/null +++ b/login.st @@ -0,0 +1,18 @@ + + + + + + $logintext$ — Gödel-Gentzen Clojure Syndication Services Super System + + + + $logintext$ +
+ Username:
+ Password:
+ +
+ + \ No newline at end of file -- cgit v1.2.3