Skip to content

Commit 41dd99a

Browse files
cpfergus1elia
andcommitted
Explicitly declare devise generated routes
We have some duplication affecting all stores using this extension and this is the first step toward removing it. E.g. the sign_in path was available at both /login and /spree_user/sign_in as `login_path` or `new_spree_user_session_path`. Co-Authored-By: Elia Schito <elia@schito.me>
1 parent a8ddecf commit 41dd99a

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

config/routes.rb

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,30 @@
1010
passwords: 'spree/user_passwords',
1111
confirmations: 'spree/user_confirmations'
1212
},
13-
skip: [:unlocks, :omniauth_callbacks],
14-
path_names: { sign_out: 'logout' },
15-
path_prefix: :user,
16-
router_name: :spree
13+
skip: :all,
1714
})
1815

1916
resources :users, only: [:edit, :update]
2017

2118
devise_scope :spree_user do
19+
# Legacy devise generated routes
20+
get 'user/spree_user/sign_in', to: 'user_sessions#new', as: :new_spree_user_session
21+
post 'user/spree_user/sign_in', to: 'user_sessions#create', as: :spree_user_session
22+
match 'user/spree_user/logout', to: 'user_sessions#destroy', as: :destroy_spree_user_session, via: Devise.sign_out_via
23+
get 'user/spree_user/password/new', to: 'user_passwords#new', as: :new_spree_user_password
24+
get 'user/spree_user/password/edit', to: 'user_passwords#edit', as: :edit_spree_user_password
25+
patch 'user/spree_user/password', to: 'user_passwords#update', as: :spree_user_password
26+
put 'user/spree_user/password', to: 'user_passwords#update'
27+
post 'user/spree_user/password', to: 'user_passwords#create'
28+
get 'user/spree_user/cancel', to: 'user_registrations#cancel', as: :cancel_spree_user_registration
29+
get 'user/spree_user/sign_up', to: 'user_registrations#new', as: :new_spree_user_registration
30+
get 'user/spree_user/edit', to: 'user_registrations#edit', as: :edit_spree_user_registration
31+
patch 'user/spree_user', to: 'user_registrations#update', as: :spree_user_registration
32+
put 'user/spree_user', to: 'user_registrations#update', as: nil
33+
delete 'user/spree_user', to: 'user_registrations#destroy', as: nil
34+
post 'user/spree_user', to: 'user_registrations#create', as: nil
35+
36+
# Custom devise routes
2237
get '/login', to: 'user_sessions#new', as: :login
2338
post '/login', to: 'user_sessions#create', as: :create_new_session
2439
match '/logout', to: 'user_sessions#destroy', as: :logout, via: Devise.sign_out_via

0 commit comments

Comments
 (0)