-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
Include Devise routes/controllers/views directly in the project #153
Conversation
It makes no sense to have all the view needed for the frontend copied over the host application except for the things related to the authentication. If people want to extend their application they probably also want to change those things. Also, it was technically very difficult to make SolidusAuthDevise work without all those things copied because it requires its components (controller, routes, views) only when SolidusSupport.frontend_available? returns true. This method retunrs false using this frontend, even using a monkey_patch, because some calls are made during the engines intialization, when the decorators are not yet loaded.
@user = Spree::User.new(user_params) | ||
if @user.save | ||
|
||
if current_order |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/IfUnlessModifier: Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
@@ -0,0 +1,67 @@ | |||
# frozen_string_literal: true | |||
|
|||
class Spree::UsersController < Spree::StoreController |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/ClassAndModuleChildren: Use nested module/class definitions instead of compact style.
%w(registration update_registration).include?(params[:action]) | ||
end | ||
|
||
def check_authorization |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lint/DuplicateMethods: Method Spree::CheckoutController#check_authorization is defined at both app/controllers/spree/checkout_controller.rb:247 and app/controllers/spree/checkout_controller.rb:278.
end | ||
|
||
def skip_state_validation? | ||
%w(registration update_registration).include?(params[:action]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/PercentLiteralDelimiters: %w-literals should be delimited by [ and ].
permit(:email) | ||
end | ||
|
||
def skip_state_validation? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lint/DuplicateMethods: Method Spree::CheckoutController#skip_state_validation? is defined at both app/controllers/spree/checkout_controller.rb:160 and app/controllers/spree/checkout_controller.rb:274.
@@ -0,0 +1,18 @@ | |||
# frozen_string_literal: true | |||
|
|||
class Spree::UserConfirmationsController < Devise::ConfirmationsController |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/ClassAndModuleChildren: Use nested module/class definitions instead of compact style.
path_names: { sign_out: 'logout' }, | ||
path_prefix: :user, | ||
router_name: :spree | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/IndentFirstHashElement: Indent the right brace the same as the first position after the preceding left parenthesis.
@@ -30,4 +32,35 @@ | |||
|
|||
get '/unauthorized', to: 'home#unauthorized', as: :unauthorized | |||
get '/cart_link', to: 'store#cart_link', as: :cart_link | |||
|
|||
devise_for(:spree_user, { | |||
class_name: 'Spree::User', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/IndentFirstHashElement: Use 2 spaces for indentation in a hash, relative to the first position after the preceding left parenthesis.
@@ -30,4 +32,35 @@ | |||
|
|||
get '/unauthorized', to: 'home#unauthorized', as: :unauthorized | |||
get '/cart_link', to: 'store#cart_link', as: :cart_link | |||
|
|||
devise_for(:spree_user, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/BracesAroundHashParameters: Redundant curly braces around a hash parameter.
|
||
|
||
delegate :login_path, :signup_path, :logout_path, | ||
to: :spree, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/AlignArguments: Align the arguments of a method call if they span more than one line.
We are making available two methods to install 1. Copying all In this case, the executable relies on 2. Adding For this installation option, the README is currently recommending adding ( However, if we add What I'd propose to fix the problem is:
rails generate solidus_starter_frontend:controllers [checkout] It would provide a better user experience and, on top of that, this issue would be fixed. |
@waiting-for-dev I'm fine trying the proposed approach! We can always use a generator to copy controllers and everything else by default if needed. 👍 Feel free to upset the installation process! |
@kennyadsl I'm closing this PR since it is now superseded by #172. |
Description
This PR explores if it makes still sense to have all the views needed for the frontend copied over the host application except for the things related to the authentication. The rationale is that if people want to extend their application they probably also want to change those parts of the application.
Also, it was technically very difficult to make SolidusAuthDevise work without all those things copied because it requires its
components (controller, routes, views) only when SolidusSupport.frontend_available? returns true. This method returns false using this frontend, even using a monkey_patch, because some calls are made during the engines initialization, when the decorators are not yet loaded.
Cons of this approach are:
solidus_starter_fronted
withoutsolidus_auth_devise
. Well, it's possible but al the devise things need to be manually removed from the host application after the installation.Motivation and Context
We want to provide a smooth installation process, and now it was impossible to have a store working with the auth provided by solidus_auth_devise.
The project will ship with a working Authentication system that uses Devise. Don't you like it? Well, you can just remove the extra code from your project after it has been copied and use what you prefer.
With another iteration, we can explore adding an install configuration (
--without-authentication
) that does not copy auth-related things if needed.How Has This Been Tested?
I tested this creating a new rails store following the README instructions updated with this PR.
Some specs are passing, some don't but that's because we need to change some things that solidus_auth_devise views changed, but it's expected.
Types of changes
Checklist: