# Fast User Switcher for Developers

**URL:** https://meta.discourse.org/t/fast-user-switcher-for-developers/69362
**Category:** Plugin
**Created:** [September 5, 2017, 1:19am UTC](https://meta.discourse.org/t/fast-user-switcher-for-developers/69362 "2017-09-05T01:19:37Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [September 5, 2017, 1:19am UTC](https://meta.discourse.org/t/fast-user-switcher-for-developers/69362/1 "2017-09-05T01:19:37Z")

</div>

As pointed out below, you don’t actually need a plugin to easily switch users in development:

> [@eviltrout](#):
>
> In development mode, visit session/USERNAME/become with a GET request and you will impersonate that user.

That said, this plugin might still be useful if you want easy links to switch accounts quickly.

* * *

When developing Discourse, I often find it’s useful to switch between user accounts. My general workflow currently looks something like this:

- Open incognito window
- Login using the admin account credentials that I remember (most of the time)
- Hamburger
- Admin
- Users
- Pick a user
- Impersonate

If I want to change to another user, or inevitably close the incognito window by accident, I repeat that process again. Gets tedious very quickly.

When experimenting with various chat systems for `discourse-chat-integration`, I installed the development version of Zulip. I really liked the way they handle authentication when running in development mode: you just click a username and you’re in!

 ![image](https://global.discourse-cdn.com/meta/original/3X/4/2/42e4919919e22ec1dc4cb767f45dd91bca41ef05.png)

So, stealing that concept, this plugin replicates that functionality in Discourse. It adds a box to the footer, containing a list of every user (max. 50) on your development instance. All you do to login is click the username 🎉. The implementation is identical to the admin “impersonate” feature, but without all the safety features.

The footer is visible on every page, so you can switch users without even logging out!

![52](https://global.discourse-cdn.com/meta/original/3X/5/0/5010a640f0e9d3c09bc071afc66fe269392eb7b4.png)

The repository is available at [https://github.com/davidtaylorhq/discourse-dev-login](https://github.com/davidtaylorhq/discourse-dev-login)

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [September 5, 2017, 1:23am UTC](https://meta.discourse.org/t/fast-user-switcher-for-developers/69362/2 "2017-09-05T01:23:45Z")

</div>

> [@david](#):
>
> but DO NOT INSTALL THIS IN PRODUCTION. It will give everyone access to every single account on your Discourse instance.

You could add a guard that only activates the plugin in development mode.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [September 5, 2017, 1:29am UTC](https://meta.discourse.org/t/fast-user-switcher-for-developers/69362/3 "2017-09-05T01:29:41Z")

</div>

> [@tgxworld](#):
>
> You could add a guard that only activates the plugin in development mode.

Good idea, [done](https://github.com/davidtaylorhq/discourse-dev-login/commit/0fba43db7118d7b5774da3e8bbadf9766dfa3061). I’ll tone the warnings down a little now 😉

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [September 5, 2017, 11:10am UTC](https://meta.discourse.org/t/fast-user-switcher-for-developers/69362/4 "2017-09-05T11:10:40Z")

</div>

Why not just use multiple browser profiles for this? Then you can hold (x) unique cookies per (x) browser profiles.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [September 5, 2017, 11:16am UTC](https://meta.discourse.org/t/fast-user-switcher-for-developers/69362/5 "2017-09-05T11:16:40Z")

</div>

I find this easier than switching between 5-6+ different browser profiles all the time `¯\_(ツ)_/¯`. This means I can just have a single browser tab which I can use for testing every user.

---

<div class="post-metadata">

### Author: ![LeoMcA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leomca/32/87233_2.png) [@LeoMcA](https://meta.discourse.org/u/LeoMcA)
#### Post date: [September 5, 2017, 12:04pm UTC](https://meta.discourse.org/t/fast-user-switcher-for-developers/69362/6 "2017-09-05T12:04:02Z")

</div>

As a middle way between one tab for multiple users, and one profile per user, I find [Firefox Containers](https://wiki.mozilla.org/Security/Contextual_Identity_Project/Containers) incredibly helpful, allowing me to have multiple tabs open, in the same profile/window, but logged in as separate users.

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [September 5, 2017, 2:33pm UTC](https://meta.discourse.org/t/fast-user-switcher-for-developers/69362/7 "2017-09-05T14:33:51Z")

</div>

There is already a hidden feature to switch users quickly by URL that you could leverage.

In development mode, visit `session/USERNAME/become` with a GET request and you will impersonate that user. So you could adjust your plugin to just link to that GET route instead.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [September 5, 2017, 2:42pm UTC](https://meta.discourse.org/t/fast-user-switcher-for-developers/69362/8 "2017-09-05T14:42:38Z")

</div>

:facepalm: So basically I’ve just reimplemented something that already existed. 🤣

Are there any other useful super-ninja features for development? Would be great to document this kind of stuff somewhere.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [September 5, 2017, 7:24pm UTC](https://meta.discourse.org/t/fast-user-switcher-for-developers/69362/9 "2017-09-05T19:24:47Z")

</div>

We should close this topic and put a warning at the top about that `GET` command for development.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [September 5, 2017, 7:27pm UTC](https://meta.discourse.org/t/fast-user-switcher-for-developers/69362/10 "2017-09-05T19:27:59Z")

</div>

I’ve added a note at the top. I still think this plugin is vaguely useful, even if it wasn’t worth the development effort 😉

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [September 6, 2017, 9:22am UTC](https://meta.discourse.org/t/fast-user-switcher-for-developers/69362/11 "2017-09-06T09:22:19Z")

</div>


