Sidekiq: Routes -authentication with devise signing out user

Created on 2 Aug 2016  路  4Comments  路  Source: mperham/sidekiq

Ruby version: 2.3.1
Sidekiq / Pro / Enterprise version(s): Sidekiq

Rails: 5.0.0

We have an app which uses sidekiq monitoring described in routes.rb as follows:

authenticate :user do
mount Sidekiq::Web => '/sidekiq'
end

But accessing the '/sidekiq' page logs the user out of devise by creating a new session.

This used to work for us when we were using Rails 4.2 a few weeks back and it still does with Rails 4.2

Most helpful comment

I received an answer on stackoverflow.

The solution is to enclose authenticate :user in devise_scope :user

devise_scope :user do
authenticate :user do
mount Sidekiq::Web => '/sidekiq'
end
end

This devise_scope :user is needed in Rails 5.0.0 but not in Rails 4.x.x

Thanks for your reply.

All 4 comments

I don't know what would cause this. You might have better luck asking on StackOverflow.

I received an answer on stackoverflow.

The solution is to enclose authenticate :user in devise_scope :user

devise_scope :user do
authenticate :user do
mount Sidekiq::Web => '/sidekiq'
end
end

This devise_scope :user is needed in Rails 5.0.0 but not in Rails 4.x.x

Thanks for your reply.

Thank you for following up!

Confirmed this is also an issue on Ruby 2.3.1, Rails 4.2.7.1, cancan 1.12, rolify 5.1
User with :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable

The great solution by @nikhilm492 work for these versions as well. Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

homanchou picture homanchou  路  3Comments

HenleyChiu picture HenleyChiu  路  4Comments

rajcybage picture rajcybage  路  3Comments

davidcelis picture davidcelis  路  3Comments

mperham picture mperham  路  4Comments