liberator

ordnungswidrig 2019-01-16T11:35:34.006500Z

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

1šŸ‘
ordnungswidrig 2019-01-16T11:36:25.007Z

The decision graph can be helpful here http://clojure-liberator.github.io/liberator/tutorial/decision-graph.html

ordnungswidrig 2019-01-16T11:47:09.007100Z

Itā€™s well possible that something is missing from the docs šŸ™‚ Can you file and issue or even better submit a patch for the docs?

ordnungswidrig 2019-01-16T11:47:24.007300Z

Soo, this option actually does seem to be missing.

kwladyka 2019-01-16T13:23:25.008200Z

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

ordnungswidrig 2019-01-16T13:27:56.009100Z

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

kwladyka 2019-01-16T16:37:16.010700Z

{: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.

kwladyka 2019-01-16T16:42:15.011900Z

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?

kwladyka 2019-01-16T16:42:43.012200Z

zooming doesnā€™t work like I wish

ordnungswidrig 2019-01-16T16:45:45.013100Z

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.

ordnungswidrig 2019-01-16T16:46:19.013800Z

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.

kwladyka 2019-01-16T16:47:01.014500Z

but then I canā€™t return :session in :authorized?

kwladyka 2019-01-16T16:47:15.015Z

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

ordnungswidrig 2019-01-16T16:47:40.015400Z

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

ordnungswidrig 2019-01-16T16:48:14.016100Z

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

ordnungswidrig 2019-01-16T16:48:24.016400Z

This will set the key session in the ctx:

ordnungswidrig 2019-01-16T16:49:00.017300Z

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

ordnungswidrig 2019-01-16T16:49:20.018100Z

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

kwladyka 2019-01-16T16:49:28.018400Z

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

kwladyka 2019-01-16T16:49:38.018900Z

ok I donā€™t know how to use it, le me think

ordnungswidrig 2019-01-16T16:49:41.019100Z

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

ordnungswidrig 2019-01-16T16:50:16.019700Z

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

kwladyka 2019-01-16T16:50:28.020Z

Thanks, see you!

kwladyka 2019-01-16T16:50:44.020500Z

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

ordnungswidrig 2019-01-16T16:51:47.021300Z

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

kwladyka 2019-01-16T17:00:06.022100Z

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