Xiaotian Guo
Xiaotian Guo

Reputation: 1645

Devise authentication for sinatra app mounted in Rails

I am using -

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!

Upvotes: 4

Views: 1236

Answers (1)

Kostia
Kostia

Reputation: 150

 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

Upvotes: 8

Related Questions