mirror of
https://github.com/vale981/lack
synced 2025-03-05 09:21:39 -05:00
Finalize session state after running delayed responses.
We want to allow delayed-response code to run before we decide whether to do things like expiring the session cookie. If session finalization is run before then, any session settings made by delayed code will be ignored. The previous implementation (a specialization on FINALIZE-STATE for function responses) is insufficient, because while the expiration itself is deferred, the decision whether to expire the session is still performed befored delayed-response code has run.
This commit is contained in:
parent
50c4f1bbbb
commit
84472bc475
1 changed files with 12 additions and 6 deletions
|
@ -35,12 +35,18 @@
|
|||
(if new-session-p
|
||||
(list :id sid :new-session t :change-id nil :expire nil)
|
||||
(list :id sid :new-session nil :change-id nil :expire nil)))
|
||||
(let ((res (funcall app env)))
|
||||
(if (and (not keep-empty)
|
||||
new-session-p
|
||||
(zerop (hash-table-count session)))
|
||||
res
|
||||
(finalize store state env res))))))
|
||||
(let ((res (funcall app env))
|
||||
(process-session (lambda (result)
|
||||
(if (and (not keep-empty)
|
||||
new-session-p
|
||||
(zerop (hash-table-count session)))
|
||||
result
|
||||
(finalize store state env result)))))
|
||||
(typecase res
|
||||
(function (lambda (responder)
|
||||
(funcall res (lambda (result)
|
||||
(funcall responder (funcall process-session result))))))
|
||||
(t (funcall process-session res)))))))
|
||||
"Middleware for session management")
|
||||
|
||||
(defun finalize (store state env res)
|
||||
|
|
Loading…
Add table
Reference in a new issue