after login i’m redirecting to another page using the following, but it doesn’t seem to preserve session information. any ideas on where i should look?
(-> (response/found "/authenticated-test")
(assoc :session (assoc session :identity user-identity)))
there isn’t even a :session
value in :params
. (I asked this in #ring too.)This is the repo https://bitbucket.org/jtth/irbportal/src/bb8382ddc933842023f8bfba4353a5dcd7a5ace1/src/clj/irbportal/routes/auth.clj#lines-49. Any help is much appreciated. Otherwise I’m gonna have to just build all this up from scratch without luminus and reitit blocking my understanding, and if I can’t get that to work I’m going back to rails and devise.
I recently just added the same thing to my luminus project, in your snippet I see there's a session
variable, where is that coming from?
For what its worth heres the snippet I have
(-> (response/ok {:username email})
(assoc :session {:username email}))
how does that deal with redirection then? this is what i’m not getting
I'm not actually going to redirect. Are you able to see if the session identity is properly set on requests after the redirect?
that is what this question is about
and how are you having someone log in without redirecting them after the POST to the login route
I'm doing a re-frame front end so I'm just setting some state on the front end when I get a 200
Ok well that’s not very helpful
Sorry
this isn’t an SPA
I figured it out. The session is fine, there’s just no way of accessing it within luminus’s layouts. Which… what is the point of the template if not to provide such things?.
If you go to layout.clj you can update render to pass it in
I am actually doing that
(defn render
"renders the HTML template located relative to resources/html"
[request template & [params]]
(content-type
(ok
(parser/render-file
template
(assoc params
:page template
:csrf-token *anti-forgery-token*
:username (get-in request [:session :identity]))))
"text/html; charset=utf-8"))
Yeah, got that. Not sure why the session info isn’t just… there for each template to get… because… what is the point of the template if it can’t?
Like, is there a reason I shouldn’t just pass :session
into each template?
Only reason I can think of is there might be secure info in there and if the whole object is passed to the template its easier to accidentally serialize it into the response. That's the only reason I could think of
Like, is it due to something having to do with buddy’s session and this? https://github.com/metosin/reitit/issues/205