From ba49528e4ba3952da10b3ebd3222761c04571394 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Sat, 28 Feb 2009 19:46:16 +0100 Subject: Redirect to requested page after login. --- cljssss-g.clj | 20 ++++++++------------ 1 file 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" -- cgit v1.2.3