Not able to be redirected to login page on brand new Rails 7 application

Please include the following information in your post:

  • Which SDK this is regarding: omniauth-auth0
  • SDK Version: 3.0.0
  • Platform Version: Ruby 3.1.2 and Rails 7.0

I have followed the official guide here to setup Auth0 on a completely new project with Rails 7.

I have the following button

<%= button_to 'Login', '/auth/auth0', method: :post %>

When I click login, I see the page load for second but nothing happens, this is all that is logged.

INFO -- : Started POST "/auth/auth0" for ::1 at 2022-05-27 10:16:41 +1200
DEBUG -- omniauth: (auth0) Request phase initiated.

I have the same issue whether running on my machine or in docker, I had recently followed the same article to add Auth0 to an existing Rails 6 application without any trouble.

It seems logout works fine as I get this in the logs

INFO -- : Started GET "/auth/logout" for ::1 at 2022-05-27 10:48:29 +1200
INFO -- : Processing by Auth0Controller#logout as HTML
INFO -- : Redirected to *redacted_auth0_logout_address*
INFO -- : Completed 302 Found in 1ms (Allocations: 509)

I tried changing the auth0 credentials and address to see if this made any difference (purposefully making them incorrect) but this doesn’t make a difference as it doesn’t seem I am getting that far to be redirected to Auth0.

I checked the FAQ here but it didn’t help as I am not getting any errors.

Is there any extra debugging information I can enable?

1 Like

I have the same problem with Rails 7. The login button doesn’t work. However if I duplicate the button it does work sometimes. I believe it’s something to do with the turbo library, but don’t have a solution yet

Disable turbo <%= button_to 'Login', '/auth/auth0', 'data-turbo': 'false' ,method: :post %>

Facing Same Issue here did you find any solution?

It works with their project (repo mentioned in quick start guid for rails) correctly, but it doesn’t work in my project.

Hello! Can you try disabling turbo and passing the prompt parameter as well? As @r3cha mentioned it seems to be an issue with turbo.

<%= button_to 'Log In', '/auth/auth0', params: {prompt: 'login'}, data: {turbo: "false"} %>

One of the features of Turbo consists of converting links form submissions into AJAX requests, which is supposed to speed up your applications thanks to Turbo Drive. In this case you’ll want to disable Turbo for the buttons’ form, so it’s not an AJAX request.

It’s also useful to pass the prompt: 'login' parameter to the authorize endpoint so Auth0 can offer a better experience. More info: Rails Authentication By Example

Let me know if this works!