Changing skins from the chooser redirects unpredictably.

Description

To replicate

  1. Log in

  2. navigate to a work https://archiveofourown.org/works/21911809

  3. scroll to skin chooser in the footer

  4. switch to Reversi

  5. Be redirected to Reversi's Skins page at https://archiveofourown.org/skins/929

  6. replicate 2-5 with LVD, Snow Blue - redirect to skin's particular /skins/###

  7. replicate 2-5 with Default - get redirected to site's top level.

Step 5 should be redirect back to the referer, or if we can't do that because we don't have the referer, redirect to the home page. https://github.com/otwcode/otwarchive/blob/6e02a48c36e3167f74fbb68d142fee80c0d77b93/app/controllers/skins_controller.rb#L120-L128

Activity

Show:
ticking instant
January 22, 2020, 11:55 PM

The reason that redirect_back_or_default doesn’t work here is because there’s no skip_before_action :store_location in the skins controller. That means that any calls to redirect_back_or_default will redirect back to the current URL (which is the one most recently stored with store_location), instead of to the referrer.

This means that the #set and #unset actions are actually visited twice any time you use the skin chooser. The first time stores its own path in session[:return_to], then redirects “back” to that same path and sets session[:return_to] = "redirected". The second time sees that it was redirected from the value of session[:return_to], so it clears session[:return_to] in store_location instead of setting it, resulting in redirect_back_or_default falling back on the default.

Assignee

Unassigned

Reporter

CJ Record

Roadmap

Skins

Priority

Medium

Affects versions

Fix versions

None

Components

None

Difficulty

Medium

Milestone

Internal 0.9
Configure