Go to page content

Shell: Reset user password

Emergency password reset when you can't get into the admin interface.

Why

Sometimes it happens that you want to reset an user's password from the Erlang shell.

Assumptions

Readers are expected to be familiar with the EShell for running Erlang code interactively.

How

You can do this from the Erlang shell without using the /admin or the reset-password mail/dialog.

First go to the Erlang shell:

In 0.6:

marc$ ./zotonic.sh shell 

And in 0.7 (and later):

marc$ ./bin/zotonic shell 

And then from the Erlang command prompt:

(zotonic52337@lantau)1> m_identity:set_username_pw(1234, "username", "password", z:c(yoursitename)). 

Where 1234 is the rsc id of your user ( 1 for the admin), this must be an integer.
And yoursitename is the name of your site.

Troubleshooting

If you get the error:

{error, admin_password_cannot_be_set}

That means you are running Zotonic >= 0.7 and are trying to change the password for the admin (user 1). From this version onwards you need to define your admin password in the site's config file. Use the property admin_password.

This page is part of the Zotonic documentation, which is licensed under the Apache License 2.0.