janko / rodauth-rails

Rails integration for Rodauth authentication framework
https://github.com/jeremyevans/rodauth
MIT License
571 stars 40 forks source link

RodAuth Route Prefix Ignored in Rails #76

Closed andyrue closed 2 years ago

andyrue commented 2 years ago

It seems when configuring the RodAuth route prefix with prefix "/auth", it's not working. I added the prefix to rodauth_app.rb, and the routes then appear to be correct when running rails rodauth:routes, but performing a request to /auth/login I get No route matches "/auth/login". POSTing to "/login" does work, even though the rodauth routes list /auth/**. Restarting the server doesn't make a difference. Do I need to do something different to change where the rodauth routes are mounted?

janko commented 2 years ago

When using setting route prefix, you also need to change

r.rodauth

to

r.on "auth" do
  r.rodauth
end

In the route block. This is required for Roda to properly route the prefixed routes.

I've been discussing with Jeremy the possibility of Rodauth automatically handling this for you, but so far we haven't agreed on a solution.

andyrue commented 2 years ago

D'oh! Thank you.