Create

Create an app user: an account in the app’s own auth collection, for signing in to the app.

This is not a login for the /admin panel. That is a PocketBase superuser, made with vela admin create; see Users for the difference.

Syntax

$ vela users create
$ vela users create                                   # asks for email, password and name
$ vela users create -t production
$ vela users create -t production --email ada@example.com --set admin=true

Whatever the flags leave out is asked for: the email, the password (typed without echo), and a name when the collection has a name field. Leave the password empty and a long random one is generated and printed once; it is stored nowhere else, and the database keeps only a hash. A password you choose has to meet the collection’s own minimum length, 8 characters unless you changed it.

The account is created with its email marked as verified, so it can sign in straight away in an app that requires verification. The command sends no email. It ends by printing where to sign in.

Off a terminal nothing is asked: pass --email, and either --password or nothing to have one generated.

Options

  • --email <email> - Email to sign in with
  • --password <password> - Password. Left out and left empty at the prompt, one is generated and shown once
  • --name <name> - Display name, when the collection has a name field
  • --verified / --no-verified - Mark the email as verified, the default for a new account, or leave it unverified
  • --set <key=value> - Set another field of the collection. Repeat for more
  • --collection <name> - Auth collection to create the account in, defaults to users
  • --update - When the email already has an account, change it instead of failing
  • -t, --target <target> - Which copy of the app to act on, defaults to local
  • --server <ssh> - Server this target runs on, recorded on first use
  • -i, --identity <file> - SSH private key to authenticate with
  • --ssh-port <port> - SSH port
  • --accept-host-keys - Trust an unknown host key on first connect (CI)

Other fields

--set writes any field the collection has beyond the ones with a flag of their own, and the field’s type decides how the value is read: --set admin=true on a bool field is the boolean, --set credits=10 on a number field is the number, and --set code=0123 on a text field stays the text it was typed as. A field the collection does not have is an error that lists the ones it does, and so is admin=yes on a bool.

$ vela users create --email ada@example.com --set admin=true --set plan=pro

An existing account

An email that already has an account is an error, so running the command twice never resets somebody’s password by accident. Pass --update to change the account instead: its password, its name, its --set fields or whether it is verified. With --update and no password, the password is left as it was.

$ vela users create -t production --email ada@example.com --update --set admin=true

Where it runs

Locally the database is opened as the superuser in .env, with the app’s hooks loaded, so a hook that runs when a user is created runs for this one too. On a target the account is created in the deployed database, over SSH. A project without a backend is refused and pointed at vela enable backend, as is a target with no deployed database.