Skip to content

Commit

Permalink
feat(Route): Accept override (lynndylanhurley#1432)
Browse files Browse the repository at this point in the history
  • Loading branch information
plribeiro3000 authored Nov 1, 2020
1 parent 530b4ba commit 24da31e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/devise_token_auth/rails/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ def mount_devise_token_auth_for(resource, opts)
omniauth_ctrl = opts[:controllers][:omniauth_callbacks] || 'devise_token_auth/omniauth_callbacks'
unlocks_ctrl = opts[:controllers][:unlocks] || 'devise_token_auth/unlocks'

# check for resource override
route = opts[:as] || resource.pluralize.underscore.gsub('/', '_')

# define devise controller mappings
controllers = { sessions: sessions_ctrl,
registrations: registrations_ctrl,
Expand All @@ -27,7 +30,7 @@ def mount_devise_token_auth_for(resource, opts)
# remove any unwanted devise modules
opts[:skip].each{ |item| controllers.delete(item) }

devise_for resource.pluralize.underscore.gsub('/', '_').to_sym,
devise_for route.to_sym,
class_name: resource,
module: :devise,
path: opts[:at].to_s,
Expand Down

0 comments on commit 24da31e

Please sign in to comment.