Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Devise authentication for sinatra app mounted in Rails

I am using -

  • Rails 3.2.2
  • Ruby 1.9.3
  • Devise 2.0.4

my route file looks like this:

Foo::Application.routes.draw do
  devise_for :admins

  root :to => "home#index"
  authenticate :admin do
    mount Simple::App, at: '/simple'
  end 
end

access under /simple needs to be authenticated.

However if not signed in , access to /simple/* will be redirect to /simple/admin/sign_in instead of just /admin/sign_in which creates a redirect loop.

Do I need to create a custom failure_app to correct this behavior?

Thanks!

like image 840
Xiaotian Guo Avatar asked Feb 21 '23 03:02

Xiaotian Guo


1 Answers

 Foo::Application.routes.draw do
   devise_for(:admins)

   root(to: 'home#index')

   match('/simple/admins/sign_in' => redirect('/admins/sign_in'))
   authenticate(:admin) do
     mount(Simple::App, at: 'simple')
   end 
 end
like image 166
Kostia Avatar answered Mar 07 '23 19:03

Kostia