liberator 2019-01-16

@kwladyka you can. Just return false from :new?

šŸ‘ 1

Thank you. I know but it is not so obviously as it looks when I don’t know deeply liberator šŸ˜‰

That’s true. Still it’s the quickes way to ā€œbacktraceā€ from the desired outcome handler and look at the decisions on the way šŸ™‚

{:allowed-methods [:post]
                              :new? false
                              :handle-no-content (fn [{:keys [request] :as ctx}]
                                                (let [{:keys [params]} request
                                                      {:keys [email password]} params]
                                                  (if-let [uuid (auth/?login->uuid email password)]
                                                    (ring-response {
                                                                    :session {:uuid uuid}})
                                                    (ring-response {:status 401
                                                                    :session nil}))))}
@ordnungswidrig so you are saying it is less weird now šŸ˜‰ So somebody try to login and get HTTP 204 šŸ˜‰ Unless I return :status 200 which is not less weird.

How do you analyse decision graph? It is too small in Safari and I can’t use cmd+f. Any trick for that to make life easier in simple way?

zooming doesn’t work like I wish

hmmm, there was an issue with the svg viewpoint in the graph which I don’t remember. You can save a copy and remove the size declaration at the very top.

On the other hand you should not explicitly set the status from a handler here but make use if :authorized?to handle the login case.

but then I can’t return :session in :authorized?

it is ok when I check if somebody is autorized, but when somebody login I feel confuse about that

you can assoc the session to the context and later return:

:authorized (fn [ctx] (if ... {:session {:uuid uuid}})

This will set the key session in the ctx:

:handle-no-content (fn [ctx] (ring-response :session (:session ctx))

I think you can make use of :as-response to retrieve the session for all handler.

hmm in the there is :authorized?, there is not :authorized http://clojure-liberator.github.io/liberator/doc/decisions.html

ok I don’t know how to use it, le me think

Regarding the decision graph the debugging wrapper might be helpful too :http://clojure-liberator.github.io/liberator/tutorial/debugging.html btw.

Need to leave now, I will have a look at the chat later today.

Thanks, see you!

Eventually maybe you have best practice code to login to paste here?

I don’t have code at hand but I can craft an example for session handling later.

Hmm it could be silly a question, but maybe I shouldn’t use liberator for login request?