Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use flickwerk-style patches #254

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 0 additions & 2 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ Gemspec/OrderedDependencies:
Layout/ArgumentAlignment:
Exclude:
- 'app/models/spree/user.rb'
- 'lib/spree/authentication_helpers.rb'
- 'spec/controllers/spree/user_sessions_controller_spec.rb'
- 'spec/features/sign_out_spec.rb'

Expand Down Expand Up @@ -351,7 +350,6 @@ Style/GuardClause:
- 'db/migrate/20120203010234_add_reset_password_sent_at_to_spree_users.rb'
- 'db/migrate/20190125170630_add_reset_password_token_index_to_spree_users.rb'
- 'db/migrate/20200417153503_add_unconfirmed_email_to_spree_users.rb'
- 'lib/spree/authentication_helpers.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Expand Down
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3')
gem 'async', '< 3', require: false
end

# Temporarily use the `solidus_support` gem with Flickwerk support
gem "solidus_support", github: "mamhoff/solidus_support", branch: "re-enable-flickwerk"

# 'net/smtp' is required by 'mail', see:
# - https://github.com/ruby/net-protocol/issues/10
# - https://stackoverflow.com/a/72474475
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

module SolidusAuthDevise
module ApplicationControllerPatch
def self.prepended(base)
return unless base.respond_to?(:helper_method)

base.send(:helper_method, :spree_current_user)

return unless SolidusSupport.frontend_available?

base.send(:helper_method, :spree_login_path)
base.send(:helper_method, :spree_signup_path)
base.send(:helper_method, :spree_logout_path)
end

def spree_current_user
current_spree_user
end

if SolidusSupport.frontend_available?
delegate :login_path, :signup_path, :logout_path,
to: :spree,
prefix: :spree
end

ApplicationController.prepend self
end
end

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

module Spree
module SolidusAuthDevise
module Admin
module BaseControllerDecorator
module BaseControllerPatch
protected

def model_class
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# frozen_string_literal: true

module SolidusAuthDevise
module Admin
module Orders
module CustomerDetailsControllerPatch
def self.prepended(base)
base.before_action :check_authorization
end

private

def check_authorization
load_order
session[:access_token] ||= params[:token]

resource = @order
action = params[:action].to_sym
action = :edit if action == :show # show route renders :edit for this controller

authorize! action, resource, session[:access_token]
end

Spree::Admin::Orders::CustomerDetailsController.prepend self
end
end
end
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Spree
module CheckoutControllerDecorator
module SolidusAuthDevise
module CheckoutControllerPatch
def self.prepended(base)
base.before_action :check_registration, except: [:registration, :update_registration]
base.before_action :check_authorization
Expand Down
2 changes: 0 additions & 2 deletions lib/solidus_auth_devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,3 @@
require 'solidus_auth_devise/configuration'
require 'solidus_auth_devise/version'
require 'solidus_auth_devise/engine'

require 'spree/authentication_helpers'
2 changes: 0 additions & 2 deletions lib/spree/auth/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ class Engine < Rails::Engine
config.to_prepare do
Spree::Auth::Engine.prepare_backend if SolidusSupport.backend_available?
Spree::Auth::Engine.prepare_frontend if SolidusSupport.frontend_available?

ApplicationController.include Spree::AuthenticationHelpers
end

def self.redirect_back_on_unauthorized?
Expand Down
27 changes: 0 additions & 27 deletions lib/spree/authentication_helpers.rb

This file was deleted.

2 changes: 1 addition & 1 deletion solidus_auth_devise.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'devise', '~> 4.1'
spec.add_dependency 'devise-encryptable', '0.2.0'
spec.add_dependency 'solidus_core', ['>= 3', '< 5']
spec.add_dependency 'solidus_support', '~> 0.5'
spec.add_dependency 'solidus_support', '~> 0.11'

spec.add_development_dependency 'solidus_backend'
spec.add_development_dependency 'solidus_frontend'
Expand Down