smpallen99/coherence

Masquerade

Opened this issue · 3 comments

How would you recommend going about creating a masquerade feature? Is this something you'd be interested in seeing as a PR?

@carterbryden I might take a crack at this myself. As much as I don’t think I like the feature, it’s very useful for some people on my team when customers are having trouble.

@carterbryden I have this working for my needs currently, although it's a pretty crude, non reusable solution. Im using the following code in a protected admin controller.

# ...current_user permissions check not included

# Log the current user out
conn =
  Coherence.Config.auth_module
  |> apply(Coherence.Config.delete_login(), [conn, [id_key: Coherence.Config.schema_key()]])

# Login the new specified user
Coherence.Config.auth_module
|> apply(Coherence.Config.create_login(), [conn, user, [id_key: Coherence.Config.schema_key()]])
|> redirect(to: page_path(conn, :index))

I have this feature on a private branch. I'll see if I can get some time to merge it. BTW, it only works in dev builds so there shouldn't be any security concerns for production deployment.