The code here shows that devise will redirect to the currently requested path when the session times out (which is checked and enforced by the timeoutable module) : https://github.com/plataformatec/devise/blob/master/lib/devise/failure_app.rb#L120
The attempted_path is set by warden before invoking the failure app.
Question is : Why would devise redirect back to the current requested path itself? If the session has timed out then shouldn't the client be redirected to the login page for the current entity (User or Admin or whatever)?
It does use the scope_url if attempted_path is not set. But I do not understand why should a redirect be made to the currently requested path again? Wouldn't this just result in a redirect-loop?
This redirect-loop is infact happening with Rails admin. If I enable timeoutable for the model for which I am authenticating in Rails admin, then after session timeout, any request will result in a redirect loop.
So can someone please explain to me why a redirect to attempted_path is being made at all? What use case doe sit serve?
Additional info Here are the two flows that I have in mind.
How it should be
- User tries to access page x. Session is timed out.
- User is redirected to the login page
- User logs in
- User is redirected back to page x
How it is currently
- User tries to access page x. Session is timed out.
- User is redirected to page x.
And it repeats into a loop until browser says "Website is not redirecting properly".

attempted_pathis needed? This is no longer a blocker, but would be definitely very helpful to understand. - brahmana