Skip to content

Admin Lockout

DredBaron edited this page Jun 6, 2026 · 5 revisions

If you are locked out of your admin account, you can reset the password directly against the database. This requires access to the host machine running OpenMTG.

Source the environment variables

export $(grep -v '^#' .env | xargs)

Find the Admin username

docker compose exec db psql -U $POSTGRES_USER $POSTGRES_DB -c "SELECT id, username, is_admin, is_active FROM users;"

Note the exact username, case-sensitive.

Generate a bcrypt hash for your new password

docker compose run --rm --no-deps app python3 -c "import bcrypt; print(bcrypt.hashpw(b'NEWPASSWORD', bcrypt.gensalt()).decode())"

Replace yournewpassword with the new password. The output will look like: $2b$12$somehashedstringhere...

Write the hash to the database

docker compose exec db psql -U $POSTGRES_USER $POSTGRES_DB -c "UPDATE users SET hashed_password = '\$2b\$12\$HASHEDSTRINGHERE' WHERE username = 'admin';"

Replace $HASHEDSTRINGHERE with the full string output by the bcrypt command.

The terminal should report UPDATE 1. The \$ escaping is required when passing the hash on the command line.

Log in

Use the username from step 2 and the new password. No restart is required.

Clone this wiki locally