aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2009-02-28 19:46:16 +0100
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2009-02-28 19:46:16 +0100
commitba49528e4ba3952da10b3ebd3222761c04571394 (patch)
tree43ca3cb570b4baaf6b3d3cc5d3bd4da91c916db6
parentffba5d3e4895d5072a989762aea02a10be347d99 (diff)
Redirect to requested page after login.
-rw-r--r--cljssss-g.clj20
1 files changed, 8 insertions, 12 deletions
diff --git a/cljssss-g.clj b/cljssss-g.clj
index 55e7e71..1fc7bec 100644
--- a/cljssss-g.clj
+++ b/cljssss-g.clj
@@ -94,28 +94,24 @@
(defmacro with-session [& body]
`(if (not (~'session :id))
- (redirect-to "/login")
+ (if (= (~'params :valuesofbetawillgiverisetodom) "true")
+ (.toString (doto (.getInstanceOf templates "login")
+ (.setAttributes {"logintext" "Login failed"})))
+ (.toString (doto (.getInstanceOf templates "login")
+ (.setAttributes {"logintext" "Login"}))))
(do ~@body)))
(defservlet cljssss-g
- (GET "/login"
- (if (= (params :valuesofbetawillgiverisetodom) "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?valuesofbetawillgiverisetodom=true"))))))
+ (when (= password (params :password))
+ (alter session assoc :id id))
+ (redirect-to (or (headers :referer) "/"))))))
(GET "/feedlist.opml"
(with-session (opml-string (session :id))))
(GET "/lynxy-feedlist.html"