Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Location Storage #231

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

cpfergus1
Copy link
Contributor

Description

Fixes the new store location feature introduced in #228

Motivation and Context

We replaced the method #redirect_back_or_default and the class user_last_url_storer because Devise already provides functionality similar to redirect_back_or_default. After emerging PR#228 We noticed that the redirects were not working as intended and investigated the cause. We found a couple of issues that we missed and needed to be rectified, specifically:

We need to Authenticate the user and not rely on authorization
Utilize spree_user instead of spree_current_user since that is the scope being utilized
Use implemented custom paths instead of devise helpers for certain routes

How Has This Been Tested?

The current test suite covers the changes made in the PR - quadrupled checked 👍

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

cpfergus1 and others added 2 commits September 30, 2022 05:58
With the deprecation of #redirect_back_or_default in solidus 4.0,
we can utilize Devise helpers store_location_for and stored_location_for
to provide the same functionality.

Co-Authored-By: Elia Schito <[email protected]>
@cpfergus1 cpfergus1 force-pushed the elia+connor/fix-location-storage branch from 11b3f3a to c38010d Compare September 30, 2022 12:04
cpfergus1 and others added 4 commits September 30, 2022 06:11
This method was utilized for redirect_back_or_default.
It is no longer required but we still need to store a location if we
get to this point
Previously we would fall back on authorization to determine if a user
should be able to access a certain endpoint. We should be
authenticating the user first prior to checking if the specific user is
authorized to access a certain endpoint

Co-Authored-By: Elia Schito <[email protected]>
When failing authentication, the devise route would send the user
to "new_spree_user_session_path", however we want our users to be
redirected to "/login." This commit deprecates the route and sends
users to "/login."
Devise utilizes spree_user scope when executing after_sign_in_path.
This is an important distinction when storing the user location as the
user would not be redirected as expected if we use spree_current_user.

Co-Authored-By: Elia Schito <[email protected]>
@cpfergus1 cpfergus1 force-pushed the elia+connor/fix-location-storage branch from c38010d to fcd8eff Compare September 30, 2022 12:14
@elia elia self-assigned this Oct 6, 2022
@elia elia added the hold label Dec 20, 2022
@elia elia marked this pull request as draft June 9, 2023 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants