Browse Source

Make resend_code route configurable

pull/2/merge
baarkerlounger 3 years ago
parent
commit
5fa6ba40d9
  1. 10
      lib/two_factor_authentication/routes.rb

10
lib/two_factor_authentication/routes.rb

@ -4,8 +4,16 @@ module ActionDispatch::Routing
def devise_two_factor_authentication(mapping, controllers) def devise_two_factor_authentication(mapping, controllers)
resource :two_factor_authentication, :only => [:show, :update, :resend_code], :path => mapping.path_names[:two_factor_authentication], :controller => controllers[:two_factor_authentication] do resource :two_factor_authentication, :only => [:show, :update, :resend_code], :path => mapping.path_names[:two_factor_authentication], :controller => controllers[:two_factor_authentication] do
collection { get "resend_code" } collection { get resend_code_path(mapping), as: "resend_code" }
end end
end end
def resend_code_path(mapping)
Devise.mappings[resource_name(mapping)].path_names[:two_factor_authentication_resend_code] || "resend_code"
end
def resource_name(mapping)
mapping.class_name.underscore.to_sym
end
end end
end end

Loading…
Cancel
Save