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 routing and location storage #230

Conversation

cpfergus1
Copy link
Contributor

@cpfergus1 cpfergus1 commented Sep 22, 2022

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 cpfergus1 force-pushed the elia+connor/fix-routing-and-location-storage branch from 03953ee to bd712b5 Compare September 22, 2022 16:15
@cpfergus1 cpfergus1 changed the title Elia+connor/fix routing and location storage fix routing and location storage Sep 22, 2022
@cpfergus1 cpfergus1 marked this pull request as ready for review September 22, 2022 16:23
@cpfergus1 cpfergus1 force-pushed the elia+connor/fix-routing-and-location-storage branch 2 times, most recently from 2156469 to 22aea03 Compare September 22, 2022 19:57
cpfergus1 and others added 5 commits September 22, 2022 13:59
We have some duplication affecting all stores using this extension
and this is the first step toward removing it.

E.g. the sign_in path was available at both /login and /spree_user/sign_in
as `login_path` or `new_spree_user_session_path`.

Co-Authored-By: Elia Schito <elia@schito.me>
Co-Authored-By: Elia Schito <elia@schito.me>
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 <elia@schito.me>
When checking out, if a user is not registered, they will be redirected
to the registration path. This path does not need to be authenticated
and therefore will not have the user's last location stored. We need to
store the user's location if redirected.

Co-Authored-By: Elia Schito <elia@schito.me>
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 <elia@schito.me>
@cpfergus1 cpfergus1 force-pushed the elia+connor/fix-routing-and-location-storage branch from 22aea03 to 0b80068 Compare September 22, 2022 20:02
Co-Authored-By: Elia Schito <elia@schito.me>
@cpfergus1 cpfergus1 force-pushed the elia+connor/fix-routing-and-location-storage branch from 0b80068 to 2f9b1f6 Compare September 23, 2022 11:58
@cpfergus1
Copy link
Contributor Author

Closing in favor of #231

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant