-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Deprecate method #redirect_back_or_default #4533
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
Deprecate method #redirect_back_or_default #4533
Conversation
159765d to
3af4a82
Compare
3af4a82 to
76c1adf
Compare
|
|
||
| def redirect_back_or_default(default) | ||
| redirect_to(session["spree_user_return_to"] || default) | ||
| def stored_location_or(fallback_location) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably implement it in solidus_auth_devise
76c1adf to
d07e8a3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @cpfergus1! Putting it on hold until the PRs on the extensions are ready.
dbc4f8c to
4f139c9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Connor, I just left a question.
| # or its subclasses. The controller will be passed to each rule for matching. | ||
| def initialize(controller) | ||
| @controller = controller | ||
| Spree::Deprecation.warn("This class will be removed without replacement on the realease of Solidus 4.0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But are we still using this in core here? If it's not called anymore, that method should be deprecated as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point!
I also removed that method from solidus_starter_frontend and solidus_auth_devise!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Devise has a nearly identical method for storing a user's location and returning a path to navigate to. Deprecating to simplify the code base.
856f5f8 to
57fb533
Compare
57fb533 to
16bc67a
Compare
We can safely eliminate the class when #redirect_back_or_default is removed. This commit also deprecates #store_location which is the only method that utilizes this class.
16bc67a to
a6de90e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Connor, excellent work!
We deprecated `#redirect_back_or_default` method in solidusio#4533 [1]. However, the original plan was halted because of auth problems in solidus_auth_devise. See solidusio/solidus_auth_devise/232 for details. [1] - solidusio#4533 [2] - solidusio/solidus_auth_devise#232
We deprecated `#redirect_back_or_default` method in solidusio#4533 [1]. However, the original plan was halted because of auth problems in solidus_auth_devise. See solidusio/solidus_auth_devise/232 [2] for details. [1] - solidusio#4533 [2] - solidusio/solidus_auth_devise#232
Summary
Rails introduced redirect_back in rails 5+ and redirect_back_or_to in rails 7+. The naming of Solidus method #redirect_back_or_default lead to some confusion between the two methods and it appeared that it could be replaced by the included Rails methods to eliminate redundancy and simplify the code. After further investigation, the two functions create different results and cannot be used interchangeably. Devise, however, already contains a similar function to #redirect_back_or_default, so the functionality would be best moved to solidus_auth_devise.
This will affect the following gems
solidus_frontend - solidusio/solidus_frontend#9
solidus_starter_frontend - solidusio/solidus_starter_frontend#241
solidus_auth_devise - solidusio/solidus_auth_devise#228
solidus_social - solidusio-contrib/solidus_social#109
solidus_active_shipping - archived, No plans to update
solidus_paypal_marketplace - solidusio-contrib/solidus_paypal_marketplace#103
Checklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs:
The following are not always needed (
cross them outif they are not):I have attached screenshots to demo visual changes.I have opened a PR to update the guides.I have updated the readme to account for my changes.