diff options
author | christoph <christoph@debian.uxul.homelinux.org> | 2009-02-20 22:30:20 +0100 |
---|---|---|
committer | christoph <christoph@debian.uxul.homelinux.org> | 2009-02-20 22:30:20 +0100 |
commit | eb9939d459cc177f87e0f2ca25d8ff415bed8c59 (patch) | |
tree | 5cca879ff12d726a3bd6071eb249916d69784f1f | |
parent | fd47a96c0bb0484a7ba8387596d62613883f8651 (diff) |
Funktionen zum Login, Loginseite erstellt
-rw-r--r-- | cljssss-g.clj | 38 | ||||
-rw-r--r-- | login.st | 18 |
2 files changed, 45 insertions, 11 deletions
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 @@ +<?xml version="1.0" ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title>$logintext$ — Gödel-Gentzen Clojure Syndication Services Super System</title> + </head> + + <body> + $logintext$ + <form action="do_login" method="POST"> + Username: <input name="name" type="text" /> <br /> + Password: <input name="password" type="password" /> <br /> + <input type="submit" value="Log In" /> + </form> + </body> +</html>
\ No newline at end of file |