Skip to content

Commit

Permalink
Add route names to rodauth:routes rake task
Browse files Browse the repository at this point in the history
This helps with knowing the expected output of `current_route`, as well as
limiting controller callbacks to certain routes.
  • Loading branch information
janko committed Dec 29, 2024
1 parent 29ffd98 commit 2a6c681
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 42 deletions.
4 changes: 2 additions & 2 deletions lib/rodauth/rails/tasks/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def call
verbs = route_verbs(route_name)

[
route_name.to_s,
verbs.join("|"),
"#{rodauth.prefix}#{path}",
"rodauth#{configuration_name && "(:#{configuration_name})"}.#{route_name}_path",
Expand All @@ -28,7 +29,7 @@ def call
padding = routes.transpose.map { |string| string.map(&:length).max }

output_lines = routes.map do |columns|
[columns[0].ljust(padding[0]), columns[1].ljust(padding[1]), columns[2]].join(" ")
[columns[0].rjust(padding[0]), columns[1].ljust(padding[1]), columns[2].ljust(padding[2]), columns[3]].join(" ")
end

puts "\n #{output_lines.join("\n ")}"
Expand Down Expand Up @@ -67,4 +68,3 @@ def configuration_name
end
end
end

80 changes: 40 additions & 40 deletions test/rake_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,46 @@ class RakeTest < ActiveSupport::TestCase
expected_output = <<~EOS
Routes handled by RodauthApp:
GET|POST /login rodauth.login_path
GET|POST /create-account rodauth.create_account_path
GET|POST /verify-account-resend rodauth.verify_account_resend_path
GET|POST /verify-account rodauth.verify_account_path
GET|POST /remember rodauth.remember_path
GET|POST /logout rodauth.logout_path
GET|POST /reset-password-request rodauth.reset_password_request_path
GET|POST /reset-password rodauth.reset_password_path
GET|POST /change-password rodauth.change_password_path
GET|POST /change-login rodauth.change_login_path
GET|POST /close-account rodauth.close_account_path
POST /unlock-account-request rodauth.unlock_account_request_path
GET|POST /unlock-account rodauth.unlock_account_path
GET /multifactor-manage rodauth.two_factor_manage_path
GET /multifactor-auth rodauth.two_factor_auth_path
GET|POST /multifactor-disable rodauth.two_factor_disable_path
GET|POST /recovery-auth rodauth.recovery_auth_path
GET|POST /recovery-codes rodauth.recovery_codes_path
GET|POST /admin/login rodauth(:admin).login_path
GET /admin/multifactor-manage rodauth(:admin).two_factor_manage_path
GET /admin/multifactor-auth rodauth(:admin).two_factor_auth_path
GET|POST /admin/multifactor-disable rodauth(:admin).two_factor_disable_path
GET|POST /admin/webauthn-auth rodauth(:admin).webauthn_auth_path
GET|POST /admin/webauthn-setup rodauth(:admin).webauthn_setup_path
GET|POST /admin/webauthn-remove rodauth(:admin).webauthn_remove_path
POST /admin/webauthn-login rodauth(:admin).webauthn_login_path
POST /jwt/login rodauth(:jwt).login_path
POST /jwt/create-account rodauth(:jwt).create_account_path
POST /jwt/verify-account-resend rodauth(:jwt).verify_account_resend_path
POST /jwt/verify-account rodauth(:jwt).verify_account_path
POST /json/login rodauth(:json).login_path
POST /json/create-account rodauth(:json).create_account_path
POST /json/verify-account-resend rodauth(:json).verify_account_resend_path
POST /json/verify-account rodauth(:json).verify_account_path
POST /json/multifactor-manage rodauth(:json).two_factor_manage_path
POST /json/multifactor-auth rodauth(:json).two_factor_auth_path
POST /json/multifactor-disable rodauth(:json).two_factor_disable_path
login GET|POST /login rodauth.login_path
create_account GET|POST /create-account rodauth.create_account_path
verify_account_resend GET|POST /verify-account-resend rodauth.verify_account_resend_path
verify_account GET|POST /verify-account rodauth.verify_account_path
remember GET|POST /remember rodauth.remember_path
logout GET|POST /logout rodauth.logout_path
reset_password_request GET|POST /reset-password-request rodauth.reset_password_request_path
reset_password GET|POST /reset-password rodauth.reset_password_path
change_password GET|POST /change-password rodauth.change_password_path
change_login GET|POST /change-login rodauth.change_login_path
close_account GET|POST /close-account rodauth.close_account_path
unlock_account_request POST /unlock-account-request rodauth.unlock_account_request_path
unlock_account GET|POST /unlock-account rodauth.unlock_account_path
two_factor_manage GET /multifactor-manage rodauth.two_factor_manage_path
two_factor_auth GET /multifactor-auth rodauth.two_factor_auth_path
two_factor_disable GET|POST /multifactor-disable rodauth.two_factor_disable_path
recovery_auth GET|POST /recovery-auth rodauth.recovery_auth_path
recovery_codes GET|POST /recovery-codes rodauth.recovery_codes_path
login GET|POST /admin/login rodauth(:admin).login_path
two_factor_manage GET /admin/multifactor-manage rodauth(:admin).two_factor_manage_path
two_factor_auth GET /admin/multifactor-auth rodauth(:admin).two_factor_auth_path
two_factor_disable GET|POST /admin/multifactor-disable rodauth(:admin).two_factor_disable_path
webauthn_auth GET|POST /admin/webauthn-auth rodauth(:admin).webauthn_auth_path
webauthn_setup GET|POST /admin/webauthn-setup rodauth(:admin).webauthn_setup_path
webauthn_remove GET|POST /admin/webauthn-remove rodauth(:admin).webauthn_remove_path
webauthn_login POST /admin/webauthn-login rodauth(:admin).webauthn_login_path
login POST /jwt/login rodauth(:jwt).login_path
create_account POST /jwt/create-account rodauth(:jwt).create_account_path
verify_account_resend POST /jwt/verify-account-resend rodauth(:jwt).verify_account_resend_path
verify_account POST /jwt/verify-account rodauth(:jwt).verify_account_path
login POST /json/login rodauth(:json).login_path
create_account POST /json/create-account rodauth(:json).create_account_path
verify_account_resend POST /json/verify-account-resend rodauth(:json).verify_account_resend_path
verify_account POST /json/verify-account rodauth(:json).verify_account_path
two_factor_manage POST /json/multifactor-manage rodauth(:json).two_factor_manage_path
two_factor_auth POST /json/multifactor-auth rodauth(:json).two_factor_auth_path
two_factor_disable POST /json/multifactor-disable rodauth(:json).two_factor_disable_path
EOS

if RUBY_ENGINE == "jruby"
Expand Down

0 comments on commit 2a6c681

Please sign in to comment.