hum, looking deep into devise make me loose the goal I initialy wanted
to reach. Let me explain :
I have a session var that is used everywhere on the app and that is
based on this :
signed_out user => var = A
signed_in user with status = 0 => var = A
signed_in user with status = 1 => var = B
So this var only changes on those actions :
1) sign_in (if status = 1)
2) sign_out (is status was 1)
3) status update (from 0 to 1)
Handling 3) is done in my app logic and doesn't matter here.
The user can sign_in only with one form (not rememberable) and logout
with the disconnect button, a session timeout or a browser closure.
So finaly, handling 1) and 2) could be done exclusively in the session
controller. No matters if the user closes is browser or the session
expires, when he comes back, the session var will be set again with
the correct value (the one for signed_out user).
What must not happen is to miss to update this var when the user
logout(or login) himself and stay on the app.
First I was setting it on each request and even if it is easier to
achieve, it's an useless code execution (with sql queries) on more
than 95% of the requests.
To conclude, what I ended up is to override "sign_in_and_redirect" and
"sign_out_and_redirect" methods as they are used by the
sessions_controller.
I think I shouldn't have some weird behavior with this.
Olivier.