Is there any way to reset multiple user’s passwords at once? It seems like the “Reset Password” option to email a user can only be triggered per user, one user at a time.
Dear @shay123
In ERPNext, there isn’t a built-in feature to reset multiple users’ passwords at once through the user interface. However, you can achieve this by using a custom script or by executing a server-side script via the bench console.
Script #
import frappe
def reset_passwords():
users = ["user1@example.com", "user2@example.com", "user3@example.com"] # List of user emails
new_password = "new_password123" # New password to set
for user in users:
user_doc = frappe.get_doc("User", user)
user_doc.new_password = new_password
user_doc.save()
frappe.db.commit()
print(f"Password reset for {user}")
reset_passwords()
- Save the script in a file, for example, reset_passwords.py.
- Run the script using the bench console.
- Navigate to your ERPNext installation directory and execute the following
command...
bench execute path.to.your.script.reset_passwords
Replace path.to.your.script with the actual path to your script file.
This method allows you to reset passwords for multiple users programmatically. Make sure to handle passwords securely and avoid hardcoding sensitive information in your scripts.
THIS IS NOT THE RECOMMENDED APPROACH - from the security perspective. Please do not deploy it - if you are the system admin.