Closed nicolasmlv closed 4 years ago
This would be tricky to implement, because Rodauth is a Rack middleware, so it doesn't define routes the same way Rails does (just like when using OmniAuth you won't see its routes either).
I've explored two possibilities: (a) using direct routes and (b) defining a separate Rake task.
So, the idea was for rodauth-rails to define something like this:
direct :login do
RodauthApp.rodauths[nil].allocate.login_path
end
The .allocate
call is needed instead of .new
because Rodauth's #initialize
requires a Roda instance to be passed in, which we don't have here. Also, I don't know if direct routes even show up in rails routes
.
Furthermore, we cannot programatically determine to which verbs a given route responds to. For example, login
, create-account
, reset-password
and reset-password-request
routes all respond to both GET and POST, but email-auth-request
responds only to POST.
The other idea I had was to define a Rake task which would print Rodauth routes:
rails rodauth:routes
I think this would almost work, but we still have the problem that we don't know all the verbs a route responds to. I don't know whether it's worthwhile to list routes if we won't be able to list verbs.
Currently You can find out the available routes by searching for *_route
methods in Rodauth's feature documentation, and then you just replace *_route
with *_path
.
thank you for the information ! Maybe it is not a needed feature and you can close the issue 👍
I thought about this some more, and the fundamental blocker for exposing any kind of routes is that Rodauth is implemented in Roda, which currently doesn't have a tool for listing routes (other than comment-based one).
If such tool will be created in the future, then it can be used to list Rodauth routes as well (and that will work in both Rails and non-Rails environments), so it doesn't seem that anything needs to be done from rodauth-rails side.
I just added the gem to a newly created app.
When I go to /login, I see the login page.
When I cmd
rails routes
, I don't see the login route. I randomly triedrodauth.login_path
and it works. Is there a way to have a list of all the added routes?