Ruby in Rails -- Redirect to Login

Hi

I have been following the tutorial for using Auth0 with Rails here Auth0 Ruby On Rails SDK Quickstarts: 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. Ruby in Rails – Redirect to Login · Issue #105 · auth0/omniauth-auth0 · GitHub

Thanks
Shane

1 Like

but you should have opened it here:

https://github.com/auth0-samples/auth0-rubyonrails-sample/tree/master/01-Login

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 Ruby in Rails – Redirect to Login · Issue #43 · auth0-samples/auth0-rubyonrails-sample · GitHub

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.