administrate icon indicating copy to clipboard operation
administrate copied to clipboard

Add Impersonate integration with devise

Open edimossilva opened this issue 1 year ago • 1 comments

  • What would you like to be able to do? Can you provide some examples?
    • At Show User Page We could add a button Impersonate at the UI. When the button is clicked The current user would be logged out and a new login would be done with the desired user.
  • How could we go about implementing that?
    • Add a method Impersonation_enabled? in the User dashboard controller with a default return to false, it can be overridden to true
  • Can you think of other approaches to the problem?
    • Instead of having a method on the controller we can use a configuration key.
    • I am not sure about the approach but I would love to work on it, if there is interest on the feature I can investigate and plan something better.

edimossilva avatar Oct 09 '23 14:10 edimossilva

I think this is a good idea, but I wonder if it should be in a plugin of some kind, rather than the core of Administrate. What do you think?

I think if we took that approach, we might need to work out how to provide the relevant sort of plugin hooks to make it possible.

nickcharlton avatar Nov 13 '23 12:11 nickcharlton

I'm not sure about this one. I think that Administrate should be independent from authentication, and users should implement their own. If anything, we should make sure that this is easy to do. I haven't tried integrating with something like Devise or Clearance, so if Administrate doesn't play well with them, that's something we should improve. Then you can use these (or anything else) to implement an impersonation mechanism.

Incidentally, the example app implements an impersonation feature in the "Customers" dashboard. See the action "Become":

customer-actions

This new action is handled in CustomersController: https://github.com/thoughtbot/administrate/blob/main/spec/example_app/app/controllers/admin/customers_controller.rb Would something like this work for you?

I'm going to close, but please do let us know if there's something that doesn't quite work. I'll be happy to reopen!

pablobm avatar Feb 23 '24 16:02 pablobm