From f94fccb4bc2208c305375b4bd59bb9ef1869c2b6 Mon Sep 17 00:00:00 2001 From: Christian Mueller Date: Sun, 19 Jan 2014 16:15:37 +0100 Subject: [PATCH] bugfix: session invalidation enabled again --- resources/public/style.less | 3 --- src/NoteHub/storage.clj | 8 +++----- src/NoteHub/views/pages.clj | 11 ++++++----- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/resources/public/style.less b/resources/public/style.less index d4c9a28..94b6b52 100644 --- a/resources/public/style.less +++ b/resources/public/style.less @@ -101,9 +101,6 @@ html, body { margin: 0; padding: 0; } -#stats tr > td:first-child { - text-align: right; -} #hero { padding-top: 5em; padding-bottom: 5em; diff --git a/src/NoteHub/storage.clj b/src/NoteHub/storage.clj index 5df4521..65f2166 100644 --- a/src/NoteHub/storage.clj +++ b/src/NoteHub/storage.clj @@ -47,11 +47,9 @@ token))) (defn invalidate-session [token] - ; Jedis is buggy & returns an NPE for token == nil - (when token - (let [was-valid (redis/sismember db sessions token)] - (do (redis/srem db sessions token) - was-valid)))) + (let [was-valid (redis/sismember db sessions token)] + (redis/srem db sessions token) + was-valid)) (defn edit-note [noteID text] diff --git a/src/NoteHub/views/pages.clj b/src/NoteHub/views/pages.clj index d96648e..3061fcf 100644 --- a/src/NoteHub/views/pages.clj +++ b/src/NoteHub/views/pages.clj @@ -157,7 +157,9 @@ psk (storage/get-psk pid)] (if (storage/valid-publisher? pid) (let [resp (api/post-note note pid (api/get-signature (str pid psk note)) password)] - (if (get-in resp [:status :success]) + (if (and + (storage/invalidate-session session) + (get-in resp [:status :success])) (redirect (:longURL resp)) (response 400))) (response 500))) @@ -179,8 +181,8 @@ ; Here lives the API (defpage "/api" args - (let [title (get-message :api-title)] - (layout title [:article.markdown (slurp "API.md")]))) + (layout (get-message :api-title) + [:article.markdown (slurp "API.md")])) (defpage [:get "/api/note"] {:keys [version noteID]} (generate-string (api/get-note noteID))) @@ -189,5 +191,4 @@ (generate-string (api/post-note note pid signature password))) (defpage [:put "/api/note"] {:keys [version noteID note pid signature password]} - (generate-string (api/update-note noteID note pid signature password))) - + (generate-string (api/update-note noteID note pid signature password))) \ No newline at end of file