Deprecate try_spree_current_user#3923
Conversation
96abb82 to
fbe348d
Compare
fbe348d to
539ec3c
Compare
spaghetticode
left a comment
There was a problem hiding this comment.
I like this deprecation, @elia thank you 👍
jarednorman
left a comment
There was a problem hiding this comment.
Would it be preferred to fix the custom user generator? We get people in the support channel asking for help around this use case.
a208edd to
6118ae2
Compare
|
(sorry for the hiatus) |
waiting-for-dev
left a comment
There was a problem hiding this comment.
It's always so lovely removing tech debt. Thanks! 🙂
|
Hey @elia, not sure why this PR got staled. Would you mind rebasing from master? 🙏 |
6118ae2 to
106738c
Compare
|
@waiting-for-dev done ✅ |
jarednorman
left a comment
There was a problem hiding this comment.
What's the deal with the final commit? It doesn't seem related to the PR title.
@elia, what about moving it to a separated PR? 🙏 |
106738c to
48797e7
Compare
|
@jarednorman @waiting-for-dev extracted the last commit to #4440, the reason behind that was to remove all ties to devise and reduce the amount of hidden coupling we have between solidus and solidus_auth_devise. |
48797e7 to
a17d30b
Compare
| class ApplicationController < ActionController::Base | ||
| protect_from_forgery with: :exception | ||
|
|
||
| def spree_current_user |
There was a problem hiding this comment.
When using try_spree_current_user you can get away with not setting up any authentication and it will just return nil. By not using it we're relying more on the expectation on ApplicationController to implement this method. For test purposes having a no-op method is equivalent of using try_spree_current_user without an auth implementation.
It was introduced 9 years ago to overcome an obscure call loop in the early days of Spree (a00d703) and to support both a custom helper (spree_current_user) and the helper generated by Devise (current_spree_user). Then, 8 years ago, solidus_auth_devise actually added support for the official custom helper (spree_current_user) making try_spree_current_user finally unnecessary (solidusio/solidus_auth_devise@69269765).
a17d30b to
201d0e8
Compare
|
@elia, do we need to update solidus_auth_devise calls now? |
|
I wonder if we still need to support the method through |
I'm quite sure that since auth-devise will implement
Good call, I'll send a pr for auth-devise 👍 |
The current gem is defining `spree_current_user` so we don't need to be defensive about using it directly. Related to solidusio/solidus#3923.
We deprecated `#try_spree_current_user` in favor of `#spree_current_user` in solidusio#3923 [1]. The former defaulted to `nil` when no authentication library was present, but the latter was simply not defined under those circumstances. This commit restores the old behavior, as the code base works with the assumption that current user is nil when no extension has defined it (e.g. [2] & [3]). The issue was raised in the support channel [4]. [1] - solidusio#3923 [2] - https://github.com/nebulab/solidus/blob/fee8a860c068b6ad050f9b2ff9052aadf9d56174/backend/app/controllers/spree/admin/base_controller.rb#L36 [3] - https://github.com/nebulab/solidus/blob/fee8a860c068b6ad050f9b2ff9052aadf9d56174/backend/app/controllers/spree/admin/cancellations_controller.rb#L33 [4] - https://solidusio.slack.com/archives/C0JBKDF35/p1657030519259159?thread_ts=1657019907.668419&cid=C0JBKDF35
We deprecated `#try_spree_current_user` in favor of `#spree_current_user` in solidusio#3923 [1]. The former defaulted to `nil` when no authentication library was present, but the latter was simply not defined under those circumstances. This commit restores the old behavior, as the code base works with the assumption that current user is `nil` when no extension has defined it (e.g. [2] & [3]). The issue was raised in the support channel [4]. [1] - solidusio#3923 [2] - https://github.com/nebulab/solidus/blob/fee8a860c068b6ad050f9b2ff9052aadf9d56174/backend/app/controllers/spree/admin/base_controller.rb#L36 [3] - https://github.com/nebulab/solidus/blob/fee8a860c068b6ad050f9b2ff9052aadf9d56174/backend/app/controllers/spree/admin/cancellations_controller.rb#L33 [4] - https://solidusio.slack.com/archives/C0JBKDF35/p1657030519259159?thread_ts=1657019907.668419&cid=C0JBKDF35
We deprecated `#try_spree_current_user` in favor of `#spree_current_user` in solidusio#3923 [1]. The former defaulted to `nil` when no authentication library was present, but the latter was simply not defined under those circumstances. This commit restores the old behavior, as the code base works with the assumption that current user is `nil` when no extension has defined it (e.g. [2] & [3]). The issue was raised in the support channel [4]. [1] - solidusio#3923 [2] - https://github.com/solidusio/solidus/blob/fee8a860c068b6ad050f9b2ff9052aadf9d56174/backend/app/controllers/spree/admin/base_controller.rb#L36 [3] - https://github.com/solidusio/solidus/blob/fee8a860c068b6ad050f9b2ff9052aadf9d56174/backend/app/controllers/spree/admin/cancellations_controller.rb#L33 [4] - https://solidusio.slack.com/archives/C0JBKDF35/p1657030519259159?thread_ts=1657019907.668419&cid=C0JBKDF35
This fixes SolidusStarterFrontend after the changes in solidusio/solidus#3923 (Deprecate try_spree_current_user). WARNING: this change causes two examples in the `templates/spec/system/checkout_spec.rb` to reveal that they are broken. They will be fixed in the next commit.
Please, use spree_current_user instead. Ref solidusio#3923
Please, use spree_current_user instead. Ref solidusio#3923
Please, use spree_current_user instead. Ref solidusio#3923
Please, use spree_current_user instead. Ref solidusio#3923
Please, use spree_current_user instead. Ref solidusio#3923
Please, use spree_current_user instead. Ref solidusio#3923
Please, use spree_current_user instead. Ref solidusio#3923
Please, use spree_current_user instead. Ref solidusio#3923
Please, use spree_current_user instead. Ref solidusio#3923
Please, use spree_current_user instead. Ref solidusio#3923
Description
It was introduced 9 years ago to overcome an obscure call loop in the early days of Spree (a00d703) and to support both a custom helper (
spree_current_user) and the helper generated by Devise (current_spree_user).Then, 8 years ago,
solidus_auth_deviseactually added support for the official custom helper (spree_current_user) makingtry_spree_current_userfinally unnecessary (solidusio/solidus_auth_devise@69269765).Checklist: