LogoLogo
v2.2.0
v2.2.0
  • 🌸What is Petal Pro?
  • πŸ’‘Changelog
  • ⏫Upgrade guide
  • Guides
    • πŸš€Creating a web app from start to finish
    • 🌎Deploy to Fly.io
    • πŸ’³Adding a subscription
    • πŸ”’Creating Your Own API
    • πŸ”ŒContent Editor - adding your own plug-in
  • πŸ‘©β€πŸ³Recipes
    • πŸ’How to apply a recipe with git cherry pick
    • #️⃣UUIDs
    • ✍️First/Last name
    • πŸ—ΊοΈGoogle Maps
    • Password Hashing for Windows
  • Fundamentals
    • πŸ’ΏInstallation
    • πŸ“‚Folder structure
    • πŸ—ƒοΈIncluded Pages
    • πŸ˜€Users & Authentication
    • 🏒Organizations & Multitenancy
    • πŸ’³Stripe billing
    • Blog/CMS
    • πŸ””User Notifications
    • 🧊Components
    • ⬛Dark mode
    • 🎨Branding
    • 🌱Seeding
    • πŸ“„Layouts & Menus
    • πŸ–ΌοΈImage uploads
    • πŸ‘₯Impersonation
    • πŸ› οΈBackground Tasks and Jobs
    • πŸ”§Util & Helpers
    • πŸ“§Emails
    • πŸͺJavascript Hooks
    • πŸ“šExtra Hex Libraries
    • πŸ—οΈGenerators
    • πŸ—£οΈTranslations
    • πŸ–οΈContributing
    • πŸ›«Deployment
    • πŸ›‘οΈTesting
    • πŸ”’REST API
Powered by GitBook
On this page

Was this helpful?

  1. Fundamentals

Impersonation

Admins can sign in as any user

PreviousImage uploadsNextBackground Tasks and Jobs

Was this helpful?

In version 1.6 () we added the ability for admins to impersonate normal users.

This adds two routes:

post "/impersonate", UserImpersonationController, :create
delete "/impersonate", UserImpersonationController, :delete

Clicking the "Impersonate" button will perform a POST request to the above route, including the user_id of the user to be impersonated. We store the current_admin_id in the session, and sign in the admin as that user.

Once the admin has finished, the sign out button will be replaced with an "Exit impersonation" button.

This button will hit the :delete action route, which looks for current_admin_id in the session and uses it to sign in to the admin user again.

Turn off impersonation

You can toggle impersonation on/off easily in config.exs:

config :petal_pro,
  impersonation_enabled?: false
πŸ‘₯
pull request
Admin can impersonate any normal user