CLI

tenon users

Invite, recover and manage users.

tenon users manages the users of the admin from the command line. Use it to invite the first admin, to sign in again when nobody can, and in scripts. Each command does the same as its button under Manage → Users.

Commands

CommandWhat it doesWorks with --url
tenon users create [email]Invites a user and prints the invite linkYes
tenon users recover <email>Prints a link that signs the user in onceNo
tenon users listLists every user with id, name, email, role and statusNo
tenon users deactivate <email>Ends the user's sessions and blocks sign-inNo
tenon users reactivate <email>Lets a deactivated user sign in againNo
tenon users remove <email>Deletes the user. Their content staysNo

The commands without --url need the database itself, not a session. So they work even when nobody can sign in.

Invite a user

npx tenon users create editor@example.com

The CLI asks for what is missing: the email, then the role from the roles of your config. The first user is admin by default, every other user editor. With --url, the default is always editor.

It prints the invite link, and emails it too when email is set up. Without email, it warns first: pass the link on yourself.

The role. The CLI does not ask for it.Creates the user at once, with a name and a password the CLI asks for. It needs a terminal and works on the local project only.Invites through a running site. It needs tenon login as an admin.

The link opens /invite under admin.path. With admin: false there is no invite page, so use --password.

Sign in when nobody can

npx tenon users recover admin@example.com

It prints a link that signs the user in once, within an hour. Use it when Forgot password? does not help, for example because email is not set up or the last passkey is lost.

  • Opening the link signs the user out everywhere else and opens the account settings.
  • The CLI asks first. Without a terminal, pass --yes.
  • It also emails the link when email is set up.

In server code, cms.users.signInLink(email, { origin }) returns the same link.

List, deactivate and remove

npx tenon users list
npx tenon users deactivate editor@example.com
npx tenon users reactivate editor@example.com
npx tenon users remove editor@example.com
  • deactivate and remove ask first. remove has no as the default. Without a terminal, pass --yes.
  • remove cannot be undone. The user's content stays.
  • The last active admin cannot be deactivated or removed.

The site's URL

users create and users recover build their link on the URL of the CMS. They take auth.baseURL, else site.url, else they ask, with http://localhost:4321 as the default.

Without a terminal, set site.url, for example from TENON_SITE_URL. list, deactivate, reactivate, remove and --password need no URL.