Resetting user passwords through database

Howdy!

How do I reset a user password through the database?

My password expired on the system and so far, I haven’t been able to figure out how to reset the password.

I go to the users table on the database and for all passwords for all users, it shows “NoLongerUsed”. I don’t see anywhere else where passwords are stored so I can reset mine?

TIA.

Check this post:

Hello @northylikewoah
Please note that I am not a dev so I can’t tell you the mechanics of the process. But in order to reset a password you must use the User Profile form. Log into OpenEMR as a user with admin ACL, open your expired user’s profile and set the password (see OpenEMR 7 Create User Accounts - OpenEMR Project Wiki )

That password setting function has some encryption routine in it that writes the encrypted passwd to the database so you can’t just go into the database and manually edit it.
Best- Harley

IF, and only IF, you are absolutely sure that you know the correct account password, and it truly is an expiration issue, you can gain access using the known password by adjusting the password expiration, active and last changed dates in the ‘users’ & ‘users_secure’ tables in the database. Note that this is not something that you should do unless all other options are exhausted, and highly recommend that you make backups of those 2 tables before performing any manual changes to the fields, as you could easily destroy all user access to your site with one mistake.

Fields you must adjust are as follows.

In users:
-make sure ‘active’ is set to ‘1’ , not ‘0’
-change the ‘last_updated’ field to yesterday’s date

In users_secure:
-change ‘last_update’ to yesterday’s date
-change ‘last_update_password’ to yesterday’s date, or at least something inside your password expiration period

You may also need to reset ‘login_fail_counter’ to 0, if your attempts to log in have your account locked in addition to the expired password.

I cannot emphasize enough how dangerous it is to be making manual database edits if you’re not completely sure of what you’re doing. Take the extra minutes to make backups, the consequences of not doing so can be disastrous.

The following php script will allow you to regain access and change your password if your password has expired. Note it does not work if you’ve forgotten your password. You should remove this file once you’ve run it. Place it in on the server where you have openemr installed. If you have it installed in a different location, change line 9.

Change the $currentPassword variable to what your password is currently set to.

Run it as the following:

php unlock_admin.php EnterNewAdminPasswordHere

This script is put on the docker machines by default in the latest versions of OpenEMR under the /root/ directory of the server.