-
-
Notifications
You must be signed in to change notification settings - Fork 122
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
RFC: Support Backend-Only Stores #96
RFC: Support Backend-Only Stores #96
Conversation
@stewart You may be able to continue to use the
Also, you may not, I didn't get too far into it. Nice work! |
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.
I think this is a great improvement. Admin user management should be separated from the frontend.
There is a failing spec, that might be because we did not updated devise_for
in the admin
scope. But I'm not sure.
Could you please add a CHANGELOG for this?
config/routes.rb
Outdated
@@ -55,11 +55,16 @@ | |||
path_prefix: :user | |||
}) | |||
|
|||
devise_scope :spree_user do | |||
devise_scope :admin_spree_user do |
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.
I'm asking myself if we also need to change the devise_for
above to admin_spree_user
?
I've updated this per @dgra's suggestion - now uses the Additionally, I've removed the auto-generated routes, as we already generate pretty alternatives. This is the routes diff from an example application, between the last release and this PR: diff --git a/before b/after
index d49ee08..7842ffa 100644
--- a/before
+++ b/after
@@ -2,18 +2,14 @@ Prefix Verb URI Pattern Controller#Action
spree / Spree::Core::Engine
Routes for Spree::Core::Engine:
- new_admin_spree_user_session GET /user/spree_user/sign_in(.:format) spree/admin/user_sessions#new
- admin_spree_user_session POST /user/spree_user/sign_in(.:format) spree/admin/user_sessions#create
- destroy_admin_spree_user_session GET /user/spree_user/logout(.:format) spree/admin/user_sessions#destroy
- new_admin_spree_user_password GET /user/spree_user/password/new(.:format) spree/admin/user_passwords#new
- edit_admin_spree_user_password GET /user/spree_user/password/edit(.:format) spree/admin/user_passwords#edit
- admin_spree_user_password PATCH /user/spree_user/password(.:format) spree/admin/user_passwords#update
- PUT /user/spree_user/password(.:format) spree/admin/user_passwords#update
- POST /user/spree_user/password(.:format) spree/admin/user_passwords#create
admin_unauthorized GET /admin/authorization_failure(.:format) spree/admin/user_sessions#authorization_failure
admin_login GET /admin/login(.:format) spree/admin/user_sessions#new
admin_create_new_session POST /admin/login(.:format) spree/admin/user_sessions#create
admin_logout GET /admin/logout(.:format) spree/admin/user_sessions#destroy
+ admin_recover_password GET /admin/password/recover(.:format) spree/admin/user_passwords#new
+ admin_reset_password POST /admin/password/recover(.:format) spree/admin/user_passwords#create
+ admin_edit_password GET /admin/password/change(.:format) spree/admin/user_passwords#edit
+ admin_update_password PUT /admin/password/change(.:format) spree/admin/user_passwords#update
admin_search_users GET /admin/search/users(.:format) spree/admin/search#users
admin_search_products GET /admin/search/products(.:format) spree/admin/search#products
home_admin_dashboards GET /admin/dashboards/home(.:format) spree/admin/dashboards#home |
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.
👍 💯
👍 but I think we could use a rebase of the commits which toggle the name of the routes. |
Has this been approved to merge? |
f9434e5
to
ae77ed3
Compare
@stewart I'm still a huge fan of this change! Would you mind to rebase and have a look into the failing specs? |
ae77ed3
to
fc1504d
Compare
Rebased again - there are a couple of outstanding failures when paired with Solidus' If there's anything more that needs to be done to get this PR ready-to-go, please let me know. |
This commit introduces some breaking changes to solidus_auth_devise supporting Solidus stores that use solidus_backend, but have custom front-ends (read: do not use solidus_frontend). These changes mainly take the form of scope corrections to the admin scoped controllers, moving from `spree_user` to `admin_spree_user`, which Devise is expecting. This includes changes to the routes, controllers, and views. Additionally, a small change has been made to `Spree::AuthenticationHelpers` to allow it to support both `spree_user` and `admin_spree_user` Devise scopes. The routes for password reset have also been added to the admin scope to allow the full Devise recovery flow to be followed. A corresponding change to the Devise initialiser is required to allow Devise to pick up on the Spree routes.
This commit updates the backend route configuration for Devise to remove the `admin_` prefix from resource references. This ensures we can always use `spree_user` to refer to the User model from controllers, and the authentication helpers.
This commit updates the backend route configuration for Devise, to skip generating the default route set. We already specify these routes with much more convenient names (`/admin/login` vs `/user/spree_user/sign_in`).
fc1504d
to
b2018ea
Compare
Rebased once more and green across the board. Based on the two 👍s already given, I'm going to merge this. |
👍 |
This PR introduces some changes to
solidus_auth_devise
supporting Solidus stores that usesolidus_backend
, but have custom front-ends (read: do not usesolidus_frontend
).The routes for password reset have also been added to the admin scope to allow the full Devise recovery flow to be followed. A corresponding change to the Devise initialiser is required to allow Devise to pick up on the Spree routes. Additionally, the configuration of the admin routes has been updated.