Skip to content

Can't get session params needed for redirection after timeout #48

@pabvald

Description

@pabvald

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))
  end

When a timeout occurs and the timeout method is called, I need the following parameters to redirect to the correct page:

  1. login_source: this is stored in the session and determines from which application the current user logged in (A or B).
  2. customer: the name of the customer. Different customers have different stylesheets. This can be obtained from the current user.
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions