Ruby in Rails -- Redirect to Login

Hi

I have been following the tutorial for using Auth0 with Rails here https://auth0.com/docs/quickstart/webapp/rails/01-login

The issue I have is that most Rails applications (and ours is one of them) , if I hit a URL that needs a login, it will redirect me to the login screen, and then upon successful authentication continue on it’s merry journey.

I haven’t found anything in the documentation about how to do that redirect?

I have had to construct a URL myself … that seems to work … but it’s been a bit of trial and error and I would have thought that there was a better Rails way.

state = SecureRandom.hex
session['omniauth.state'] =  state
callback_url = auth_auth0_callback_url
url = "https://#{ApplicationConfig::Auth0::DOMAIN}/authorize?response_type=code&client_id=#{ApplicationConfig::Auth0::CLIENT_ID}&redirect_uri=#{callback_url}&state=#{state}&scope=openid profile email"

So is there a better way of doing this?

Cheers
Shane

Hey there Shane!

It would be best if you open a GitHub issue in the quickstart repo so the quickstart maintainers can address that directly for you. Make sure to share the link to it here with us so we can ping them. Thanks!

Hi Konrad

I submitted an issue as you suggested. https://github.com/auth0/omniauth-auth0/issues/105

Thanks
Shane

1 Like

but you should have opened it here:

as this is the repo for the quickstart you use.

Share the link to the issue once you have it and please the previous one you opened in another repo.

Ok, Here is issue https://github.com/auth0-samples/auth0-rubyonrails-sample/issues/43

1 Like

Thank you! I will ping repo maintainers in a few minutes!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.