-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make --authentication=none the same as --with-authentication=false
It seemed smart to have `--authentication=none` allow to browse the store (including /admin) without needing to sign in. Turned out that the dummy app uses it and extensions rely on the absence of authentication. Reverting to the previous behavior will fix the CI of a number of extensions.
- Loading branch information
Showing
4 changed files
with
26 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
core/lib/generators/solidus/install/app_templates/authentication/custom.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
initializer 'spree_authentication.rb', <<~RUBY | ||
# Please replace this module with your own implementation of | ||
# ApplicationController#spree_current_user. | ||
# | ||
# The current setup will allow doing guest checkouts. | ||
ActiveSupport.on_load(:action_controller) do | ||
def spree_current_user | ||
# Define here your custom logic for retrieving the current user | ||
nil | ||
end | ||
end | ||
# Re-raise the original authorization error on anauthorized access | ||
Rails.application.config.to_prepare do | ||
Spree::BaseController.unauthorized_redirect = -> { raise "Define the behavior for unauthorized access in \#{__FILE__}." } | ||
end | ||
RUBY | ||
|
||
create_file 'app/views/spree/admin/shared/_navigation_footer.html.erb', <<~ERB | ||
<!-- Add here your login/logout links in 'app/views/spree/admin/shared/_navigation_footer.html.erb'. --> | ||
ERB |
32 changes: 1 addition & 31 deletions
32
core/lib/generators/solidus/install/app_templates/authentication/none.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1 @@ | ||
initializer 'spree_no_authentication.rb', <<~RUBY | ||
# Please replace this module with your own implementation of | ||
# ApplicationController#spree_current_user. | ||
# | ||
# The current setup will allow doing guest checkouts and visitng | ||
# the /admin area without requiring any authentication. | ||
module SpreeNoAuthentication | ||
def self.install! | ||
# Set #spree_current_user to nil for all controllers | ||
ActiveSupport.on_load(:action_controller) do | ||
def spree_current_user | ||
nil | ||
end | ||
end | ||
# Re-raise the original authorization error on anauthorized access | ||
Rails.application.config.to_prepare do | ||
Spree::BaseController.unauthorized_redirect = -> { raise } | ||
end | ||
# Provide the "default" role with full permissions on everything | ||
Spree.config do |config| | ||
config.roles.assign_permissions :default, ['Spree::PermissionSets::SuperUser'] | ||
end | ||
end | ||
install! | ||
end | ||
RUBY | ||
|
||
create_file 'app/views/spree/admin/shared/_navigation_footer.html.erb', '' | ||
# noop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters