Skip to content

Commit e067b93

Browse files
committed
chore: Use Alchemy.config for auth accessors
Alchemy 8.1 introduced configuration for all auth accessors. This makes the deprecation go away, but we only can support Alchemy >= 8.1 from now on.
1 parent 246c42e commit e067b93

6 files changed

Lines changed: 14 additions & 15 deletions

File tree

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,17 @@ To use Solidus Auth Devise, instruct Alchemy to use the `Spree::User` class:
9999

100100
```ruby
101101
# config/initializers/alchemy.rb
102-
Alchemy.user_class_name = 'Spree::User'
103-
Alchemy.current_user_method = :spree_current_user
102+
Alchemy.config.user_class = 'Spree::User'
103+
Alchemy.config.current_user_method = :spree_current_user
104104
```
105105

106106
If you put Spree in it's own routing namespace (see below) you will want to
107107
let Alchemy know these paths:
108108

109109
```ruby
110110
# config/initializers/alchemy.rb
111-
Alchemy.login_path = '/store/login'
112-
Alchemy.logout_path = '/store/logout'
111+
Alchemy.config.login_path = '/store/login'
112+
Alchemy.config.logout_path = '/store/logout'
113113
```
114114

115115
#### 2. Option: Use [Alchemy Devise](https://github.com/AlchemyCMS/alchemy-devise)
@@ -161,15 +161,15 @@ and tell Solidus about Alchemy's path helpers:
161161
# lib/spree/authentication_helpers.rb
162162
...
163163
def spree_login_path
164-
Alchemy.login_path
164+
Alchemy.config.login_path
165165
end
166166

167167
def spree_signup_path
168-
Alchemy.signup_path
168+
Alchemy.config.signup_path
169169
end
170170

171171
def spree_logout_path
172-
Alchemy.logout_path
172+
Alchemy.config.logout_path
173173
end
174174
...
175175
```

alchemy-solidus.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
1414
gem.require_paths = ["lib"]
1515
gem.version = Alchemy::Solidus::VERSION
1616

17-
gem.add_dependency("alchemy_cms", [">= 8.0.0.b", "< 9"])
17+
gem.add_dependency("alchemy_cms", [">= 8.1.0.a", "< 9"])
1818
gem.add_dependency("solidus_api", [">= 4.0.0", "< 5"])
1919
gem.add_dependency("solidus_core", [">= 4.0.0", "< 5"])
2020
gem.add_dependency("solidus_backend", [">= 4.0.0", "< 5"])

app/patches/controllers/alchemy/solidus/application_controller_patch.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Alchemy
44
module Solidus
55
module ApplicationControllerPatch
66
def spree_current_user
7-
if Alchemy.user_class_name == "::Alchemy::User"
7+
if Alchemy.config.user_class_name == "::Alchemy::User"
88
current_user
99
else
1010
super

config/initializers/alchemy.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@
3535
name: "Users"
3636
}
3737
)
38-
Alchemy.user_class_name = "Spree::User"
39-
Alchemy.current_user_method = :spree_current_user
40-
38+
Alchemy.config.user_class = "Spree::User"
39+
Alchemy.config.current_user_method = :spree_current_user
4140
Rails.application.config.after_initialize do
4241
Alchemy.logout_method = Devise.sign_out_via.to_s
4342
end

lib/alchemy/solidus/engine.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Engine < ::Rails::Engine
3030
end
3131

3232
config.to_prepare do
33-
Alchemy.register_ability ::Spree::Ability
33+
Alchemy.config.abilities.add("Spree::Ability")
3434
::Spree::Ability.register_ability ::Alchemy::Permissions
3535

3636
if SolidusSupport.frontend_available?

lib/patches/backend/controllers/alchemy/solidus/spree_admin_base_controller_patch.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ module Alchemy
44
module Solidus
55
module SpreeAdminBaseControllerPatch
66
def self.prepended(base)
7-
if Alchemy.user_class_name == "::Alchemy::User"
7+
if Alchemy.config.user_class_name == "::Alchemy::User"
88
base.unauthorized_redirect = -> do
99
if spree_current_user
1010
flash[:error] = I18n.t("spree.authorization_failure")
1111
redirect_to spree.root_path
1212
else
1313
store_location
14-
redirect_to Alchemy.login_path
14+
redirect_to Alchemy.config.login_path
1515
end
1616
end
1717
end

0 commit comments

Comments
 (0)