Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Logout path should be configurable #1386

Closed
pehlert opened this Issue Nov 9, 2012 · 6 comments

Comments

Projects
None yet
6 participants

pehlert commented Nov 9, 2012

Currently, the logout button uses the default scope from warden.
While this may work in most of the setups, I am currently using rails_admin together with devise in an application that has the "sign_out_all_scopes" configuration option of devise set to false.

Thus in a setup where the scope used by rails_admin (e.g. "admin" in my case) and where this configuration option is set to false, the logout link will not work, but instead sign out a wrong scope.

While I could surely modify it, I wanted to provide the chance for some discussion in advance as it involves adding a new configuration option.

Would it be preferable to have something like "devise_scope" that could be reused in other places, or do you prefer "destroy_session_path" which is more specific to this issue (and has been proposed before, although for another reason: #788)?

Collaborator

bbenezech commented Nov 12, 2012

Sure, I would add 2 options:

  • logout_path (defaults to a block with Devise route)
  • logout_method (defaults to a block with the Devise's option)

And use them in a view helper method. Just add a couple of unit tests in spec/helpers/application_helper_spec and you will be done.

Contributor

ai commented Dec 18, 2012

I use RailsAdmin with plain OmniAuth and it will be very good, if I can show Exit button wothout devise. Maybe some SIGNOUT_PATH in RailsAdmin::Config like DEFAULT_CURRENT_USER?

@bbenezech bbenezech closed this in 3f96829 Jan 17, 2013

@bbenezech bbenezech added a commit that referenced this issue Jan 17, 2013

@bbenezech bbenezech Merge pull request #1477 from ahx/deduce-devise-scope-from-current-user
Deduce Devise scope from _current user. Fixes #1386, partly.
94748df

@bbenezech bbenezech reopened this Jan 17, 2013

Contributor

ai commented Jan 17, 2013

Logout still need Devise, because app/views/layouts/rails_admin/_secondary_navigation.html.haml call :method => Devise.sign_out_via.

Contributor

jvortmann commented Sep 5, 2014

@pehlert @bbenezech @ai I just made PR #2062 with a fix for the logout_method. It is not configurable yet, but there is a fallback to a default :delete if devise is not defined.

Also, logout_path is also kind of configurable (not by a rails_admin config though). If you have a route that defines logout_path for instance:

delete 'sign_out', :to => 'sessions#destroy', as: 'logout'

I will just work.

@sferik sferik closed this in 5b03a6e Sep 7, 2014

Contributor

carlesso commented Dec 4, 2014

This should be reopened, as Devise accepts an array for sign_out_via. A simple solution for this will be to change logout_method link this:

def logout_method
  return [Devise.sign_out_via].flatten.first if defined?(Devise)
  :delete
end

@mshibuya mshibuya reopened this Dec 5, 2014

Contributor

jvortmann commented Dec 6, 2014

@carlesso Agree. Did a pull request with this on #2128.

@mshibuya mshibuya closed this Dec 6, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment