Dev environment: recommended way to bootstrap the first admin account without email?

I’ve been experimenting with the discourse/discourse_dev Docker image (on Windows 11 laptop) and noticed a small friction point in the developer workflow.

When running Discourse in development mode without outbound email configured:
1. You can reach the signup/login page via Ember CLI (localhost:4200).
2. You can create a user account.
3. But login is blocked because email confirmation is required.

The workaround seems to be manually activating the account in the Rails console, for example:

u = User.find_by(username: "admin")
u.approved = true
u.email_tokens.update_all(confirmed: true, expired: true)
u.save!

This works, but I wondered:

Is there a recommended developer workflow for bootstrapping the first admin account when email isn’t configured?

For example:
• Should developers normally configure SMTP even in dev?
• Is there a helper task for this (rake admin:create etc.)?
• Would it make sense for the dev container to allow first-user login without email confirmation?

I’m asking mainly to document a smoother setup process for new developers experimenting with the dev container.

Yes there is:

2 Likes

Thanks! That solves it - I hadn’t come across bin/rails admin:create while experimenting with the discourse_dev container.

What initially confused me was that the normal UI signup flow works up to the point of creating the account, but login is then blocked by email confirmation if SMTP isn’t configured.

For someone just exploring the dev environment, that makes it look like the login flow is broken unless you know about the helper task.

It might be helpful to mention bin/rails admin:create explicitly in the development setup docs for the Docker dev container, since new contributors often won’t have SMTP configured.

I am not sure it’s needed in that guide because it says

So creating the admin user seems to be part of the workflow already

1 Like

If you do need email access in your dev environment, you can also run mailhog.

All you need to do is open a new command line in your Discourse directory and run mailhog. Then if you visit localhost:8025 you can see emails that would normally be sent out, no need to configure anything.

2 Likes