Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 11 additions & 18 deletions core/lib/spree/core/controller_helpers/auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,20 @@ def current_ability
end

def redirect_back_or_default(default)
Spree::Deprecation.warn <<~MSG
'Please use #stored_spree_user_location_or when using solidus_auth_devise.
Otherwise, please utilize #redirect_back provided in Rails 5+ or
#redirect_back_or_to in Rails 7+ instead'
MSG

redirect_to(session["spree_user_return_to"] || default)
session["spree_user_return_to"] = nil
end

def set_guest_token
unless cookies.signed[:guest_token].present?
cookies.permanent.signed[:guest_token] = Spree::Config[:guest_token_cookie_options].merge(
value: SecureRandom.urlsafe_base64(nil, false),
httponly: true
)
end
return if cookies.signed[:guest_token].present?

cookies.permanent.signed[:guest_token] = Spree::Config[:guest_token_cookie_options].merge(
value: SecureRandom.urlsafe_base64(nil, false),
httponly: true
)
end

def store_location
Spree::Deprecation.warn <<~MSG
store_location is being deprecated in solidus 4.0
without replacement
MSG

Spree::UserLastUrlStorer.new(self).store_location
end

Expand All @@ -83,7 +72,11 @@ def try_spree_current_user
end
end

deprecate try_spree_current_user: :spree_current_user, deprecator: Spree::Deprecation
deprecate \
try_spree_current_user: :spree_current_user,
redirect_back_or_default: 'Please use `redirect_to stored_spree_user_location_or(...)` when using solidus_auth_devise.',
Copy link
Contributor

Choose a reason for hiding this comment

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

We're losing the information when not using solidus_auth_devise, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

That information was bad, we wrote it (me and @cpfergus1) before having a clear picture of all the ramifications.

I think not having auth-devise in the store is really niche and probably something that required custom implementations anyway. What do you think about having an example implementation in the upgrading instructions?

Copy link
Contributor

Choose a reason for hiding this comment

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

That would be great, but I'm not very familiar with it. How would it look?

store_location: 'Please use `store_location_for(:spree_user, request.fullpath)` when using solidus_auth_devise.',
deprecator: Spree::Deprecation
end
end
end
Expand Down