How to recover a Strapi User
Table of contents
It’s not the first time I’ve forgotten the password for a project’s Strapi instance that I haven’t touched in a while. Sometimes, I don’t even remember the email I used to create the user.
Always use an email that works and where you can receive messages. This is especially useful when you need a password recovery link.
So, if you don’t remember the email either, the good news is that all is not lost—you can create new users using the Strapi CLI.
Creating a New User
You can run:
strapi admin:create-user --firstname=NAME --email=EMAIL --password=PASSWORD
Alternatively, without parameters: strapi admin:create-user
, and interactively, it will prompt you for an email, first name, last name, and password.
If you’re using a package manager like yarn
or npm
, you’ll need to do it like this:
yarn strapi admin:create-user --firstname=NAME --email=EMAIL --password=PASSWORD
npm run strapi admin:create-user --firstname=NAME --email=EMAIL --password=PASSWORD
Resetting a User’s Password
If you at least remember the email you used to create the user, you can run admin:reset-user-password
:
strapi admin:reset-user-password
It will ask for the email associated with the user you want to reset, the new password, and a confirmation.
Other Solutions
In some cases, you might be able to regain access by manually editing the database. It’s not the best option, but it’s worth mentioning.
Recursos
comments powered by DisqusIf you find it interesting
If you have any doubt or you want to chat about this topic, as if you find interesting the content or our profiles and you think we could build something together, do not hesitate to contact us trough the email address hola@mamutlove.com