-
Notifications
You must be signed in to change notification settings - Fork 61
Description
I have a Rails application with two mountable engines: A and B. Both engines share the same authentication system based on Devise. I also use the atuo-session-timeout gem, overriding the active and timeout methods as follows:
# GET user_sessions/active
#
# Returns the active status of the user.
def active
response.headers["Etag"] = nil # clear etags to prevent caching
render(plain: current__user.present?, status: 200)
end
# GET /api/v2/user_sessions/timeout
#
# Redirects to the timeout path.
def timeout
params_h = ... # get params from cookies
flash[:error] = I18n.t('errors.api.timeout')
redirect_to(index_path(params_h))
endWhen a timeout occurs and the timeout method is called, I need the following parameters to redirect to the correct page:
login_source: this is stored in the session and determines from which application the current user logged in (A or B).customer: the name of the customer. Different customers have different stylesheets. This can be obtained from the current user.location: which of the customer's locations was used. This can also be obtained from the current user.
However, when the timeout method is called in my sessions controller, the session has already been killed. This leaves me only one option: to store the parameters in the cookies and retrieve them from there to redirect to the correct login page.
Ideally, I would like to get these parameters from somewhere else, as cookies are being restricted more and more. In the future, if the site is embedded in an iframe, I won't even be able to get the parameters from the cookies, as they will be considered third-party cookies (see Article). This is also the case if an user has blocked all cookies in their browser.