How do you reset a user's password upon their first login?
-
Is it possible to set all users to have the passwordChangeRequired status set to true by default, so they are forced to reset their password upon their first login? Additionally, can we set a default password format as company{username}? For example, a user with the username 1234 would have the default password company1234.
-
Yes, this can be achieved using the FusionAuth API. Here's how you can implement it:
- Set the default password for each user:
Use the POST /api/user/change-password endpoint to set the user's password to the desired format, e.g., company1234. Refer to the "Change a User's Password using an email address or username" section of the FusionAuth documentation. This allows you to update a user's password in a single API call without requiring the Forgot Password flow. - Require the user to change their password:
Use the PATCH /api/user/{userId} endpoint to set the passwordChangeRequired field to true. This ensures that the user will be prompted to change their password upon their next login.
API Documentation for reference:
Optional Customization:
To guide users on the login page to use the default password format, you can customize the messaging through FusionAuth Themes:- Navigate to Simple Theme > Messages > Default.
- Add a custom message, such as password=Password is company+username, to inform users of the default password structure.
- Set the default password for each user:
-