Browse Source

bugfix: session invalidation enabled again

master
Christian Mueller 12 years ago
parent
commit
f94fccb4bc
  1. 3
      resources/public/style.less
  2. 8
      src/NoteHub/storage.clj
  3. 11
      src/NoteHub/views/pages.clj

3
resources/public/style.less

@ -101,9 +101,6 @@ html, body {
margin: 0; margin: 0;
padding: 0; padding: 0;
} }
#stats tr > td:first-child {
text-align: right;
}
#hero { #hero {
padding-top: 5em; padding-top: 5em;
padding-bottom: 5em; padding-bottom: 5em;

8
src/NoteHub/storage.clj

@ -47,11 +47,9 @@
token))) token)))
(defn invalidate-session [token] (defn invalidate-session [token]
; Jedis is buggy & returns an NPE for token == nil (let [was-valid (redis/sismember db sessions token)]
(when token (redis/srem db sessions token)
(let [was-valid (redis/sismember db sessions token)] was-valid))
(do (redis/srem db sessions token)
was-valid))))
(defn edit-note (defn edit-note
[noteID text] [noteID text]

11
src/NoteHub/views/pages.clj

@ -157,7 +157,9 @@
psk (storage/get-psk pid)] psk (storage/get-psk pid)]
(if (storage/valid-publisher? pid) (if (storage/valid-publisher? pid)
(let [resp (api/post-note note pid (api/get-signature (str pid psk note)) password)] (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)) (redirect (:longURL resp))
(response 400))) (response 400)))
(response 500))) (response 500)))
@ -179,8 +181,8 @@
; Here lives the API ; Here lives the API
(defpage "/api" args (defpage "/api" args
(let [title (get-message :api-title)] (layout (get-message :api-title)
(layout title [:article.markdown (slurp "API.md")]))) [:article.markdown (slurp "API.md")]))
(defpage [:get "/api/note"] {:keys [version noteID]} (defpage [:get "/api/note"] {:keys [version noteID]}
(generate-string (api/get-note noteID))) (generate-string (api/get-note noteID)))
@ -189,5 +191,4 @@
(generate-string (api/post-note note pid signature password))) (generate-string (api/post-note note pid signature password)))
(defpage [:put "/api/note"] {:keys [version noteID 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)))
Loading…
Cancel
Save