Skip to content

Deprecate try_spree_current_user#3923

Merged
waiting-for-dev merged 2 commits intosolidusio:masterfrom
nebulab:deprecate-try-spree-current-user
Jun 29, 2022
Merged

Deprecate try_spree_current_user#3923
waiting-for-dev merged 2 commits intosolidusio:masterfrom
nebulab:deprecate-try-spree-current-user

Conversation

@elia
Copy link
Copy Markdown
Member

@elia elia commented Feb 5, 2021

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_devise actually added support for the official custom helper (spree_current_user) making
try_spree_current_user finally unnecessary (solidusio/solidus_auth_devise@69269765).

Checklist:

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • I have updated Guides and README accordingly to this change (if needed)
  • I have added tests to cover this change (if needed)

Comment thread frontend/app/controllers/spree/checkout_controller.rb Outdated
@elia elia force-pushed the deprecate-try-spree-current-user branch 2 times, most recently from 96abb82 to fbe348d Compare February 5, 2021 21:53
@elia elia marked this pull request as ready for review February 26, 2021 09:17
@elia elia force-pushed the deprecate-try-spree-current-user branch from fbe348d to 539ec3c Compare February 26, 2021 10:00
Copy link
Copy Markdown
Member

@spaghetticode spaghetticode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this deprecation, @elia thank you 👍

Copy link
Copy Markdown
Member

@jarednorman jarednorman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be preferred to fix the custom user generator? We get people in the support channel asking for help around this use case.

@elia elia force-pushed the deprecate-try-spree-current-user branch 2 times, most recently from a208edd to 6118ae2 Compare November 18, 2021 10:23
@elia
Copy link
Copy Markdown
Member Author

elia commented Nov 18, 2021

(sorry for the hiatus)
@jarednorman I agree we should fix the custom user generator, but in the meanwhile I believe it's better not to have docs rather than misleading/broken ones. Anyway I removed that commit and will move it to a different issue/PR so it can be dealt with properly 👍

@elia elia requested a review from jarednorman November 18, 2021 10:26
Copy link
Copy Markdown
Contributor

@waiting-for-dev waiting-for-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's always so lovely removing tech debt. Thanks! 🙂

@waiting-for-dev
Copy link
Copy Markdown
Contributor

Hey @elia, not sure why this PR got staled. Would you mind rebasing from master? 🙏

@elia elia force-pushed the deprecate-try-spree-current-user branch from 6118ae2 to 106738c Compare June 15, 2022 12:55
@elia
Copy link
Copy Markdown
Member Author

elia commented Jun 15, 2022

@waiting-for-dev done ✅

Copy link
Copy Markdown
Member

@jarednorman jarednorman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the deal with the final commit? It doesn't seem related to the PR title.

Comment thread core/lib/spree/core/controller_helpers/auth.rb
@waiting-for-dev
Copy link
Copy Markdown
Contributor

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? 🙏

@elia elia force-pushed the deprecate-try-spree-current-user branch from 106738c to 48797e7 Compare June 24, 2022 09:00
@elia
Copy link
Copy Markdown
Member Author

elia commented Jun 24, 2022

@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.

@elia elia requested a review from jarednorman June 24, 2022 09:09
@elia elia force-pushed the deprecate-try-spree-current-user branch from 48797e7 to a17d30b Compare June 24, 2022 09:35
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception

def spree_current_user
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@elia elia requested a review from jarednorman June 27, 2022 12:30
elia added 2 commits June 27, 2022 14:30
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).
@elia elia force-pushed the deprecate-try-spree-current-user branch from a17d30b to 201d0e8 Compare June 27, 2022 12:30
@waiting-for-dev waiting-for-dev merged commit 8c6e205 into solidusio:master Jun 29, 2022
@waiting-for-dev waiting-for-dev deleted the deprecate-try-spree-current-user branch June 29, 2022 03:23
@waiting-for-dev
Copy link
Copy Markdown
Contributor

@elia, do we need to update solidus_auth_devise calls now?

@waiting-for-dev
Copy link
Copy Markdown
Contributor

I wonder if we still need to support the method through solidus_support. Otherwise, newer versions of solidus_auth_devise won't be compatible with older solidus versions.

@elia
Copy link
Copy Markdown
Member Author

elia commented Jun 29, 2022

I wonder if we still need to support the method through solidus_support. Otherwise, newer versions of solidus_auth_devise won't be compatible with older solidus versions.

I'm quite sure that since auth-devise will implement spree_current_user and that is also a requirement for implementing a custom auth it's not needed. Any extension could switch to be using spree_current_user even now without this PR, it's just that we kept that helper around and people went on using it because it looks safer.

@elia, do we need to update solidus_auth_devise calls now?

Good call, I'll send a pr for auth-devise 👍

elia added a commit to nebulab/solidus_auth_devise that referenced this pull request Jun 30, 2022
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.
waiting-for-dev added a commit to nebulab/solidus that referenced this pull request Jul 15, 2022
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
waiting-for-dev added a commit to nebulab/solidus that referenced this pull request Jul 15, 2022
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
waiting-for-dev added a commit to nebulab/solidus that referenced this pull request Jul 15, 2022
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
gsmendoza added a commit to solidusio/solidus_starter_frontend that referenced this pull request Jul 18, 2022
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.
cpfergus1 added a commit to cpfergus1/solidus_paypal_commerce_platform that referenced this pull request Sep 21, 2022
cpfergus1 added a commit to cpfergus1/solidus_paypal_commerce_platform that referenced this pull request Sep 26, 2022
cpfergus1 added a commit to cpfergus1/solidus_paypal_commerce_platform that referenced this pull request Sep 29, 2022
cpfergus1 added a commit to cpfergus1/solidus_paypal_commerce_platform that referenced this pull request Sep 29, 2022
kennyadsl added a commit to nebulab/solidus that referenced this pull request Mar 28, 2023
Please, use spree_current_user instead.

Ref solidusio#3923
kennyadsl added a commit to nebulab/solidus that referenced this pull request Mar 28, 2023
Please, use spree_current_user instead.

Ref solidusio#3923
kennyadsl added a commit to nebulab/solidus that referenced this pull request Mar 28, 2023
Please, use spree_current_user instead.

Ref solidusio#3923
kennyadsl added a commit to nebulab/solidus that referenced this pull request Mar 28, 2023
Please, use spree_current_user instead.

Ref solidusio#3923
kennyadsl added a commit to nebulab/solidus that referenced this pull request Apr 12, 2023
Please, use spree_current_user instead.

Ref solidusio#3923
kennyadsl added a commit to nebulab/solidus that referenced this pull request Apr 14, 2023
Please, use spree_current_user instead.

Ref solidusio#3923
kennyadsl added a commit to nebulab/solidus that referenced this pull request Apr 18, 2023
Please, use spree_current_user instead.

Ref solidusio#3923
kennyadsl added a commit to nebulab/solidus that referenced this pull request Apr 18, 2023
Please, use spree_current_user instead.

Ref solidusio#3923
kennyadsl added a commit to nebulab/solidus that referenced this pull request Apr 19, 2023
Please, use spree_current_user instead.

Ref solidusio#3923
kennyadsl added a commit to nebulab/solidus that referenced this pull request Apr 24, 2023
Please, use spree_current_user instead.

Ref solidusio#3923
tvdeyen added a commit to tvdeyen/alchemy-solidus that referenced this pull request May 18, 2023
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.

5 participants