tenon 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
| Command | What it does | Works with --url |
|---|---|---|
tenon users create [email] | Invites a user and prints the invite link | Yes |
tenon users recover <email> | Prints a link that signs the user in once | No |
tenon users list | Lists every user with id, name, email, role and status | No |
tenon users deactivate <email> | Ends the user's sessions and blocks sign-in | No |
tenon users reactivate <email> | Lets a deactivated user sign in again | No |
tenon users remove <email> | Deletes the user. Their content stays | No |
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.
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
deactivateandremoveask first.removehas no as the default. Without a terminal, pass--yes.removecannot 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.
Related resources
- Access control: users and roles in the admin.
- Authentication: sign-in methods and recovery.
- Email: send invites and sign-in links by email.