Skip to main content

Reset User Password (Admin)

POST 

/company/auth/reset/:id

Endpoint to reset a user's password (administrative operation).
Generates a new random password and sends it via email.

Allow administrators to reset any user's password by generating a secure temporary password and sending it via email.

Use Cases

  • Administrator needs to reset the password of a locked user
  • User cannot access their account and requires administrative intervention
  • Technical support resets user credentials

Process Flow

  1. Administrator requests a password reset for a user
  2. Middleware m.isGestor verifies the user has a manager/admin/dev role (401 if not)
  3. Client sends a POST request with the user ID in the URL
  4. Server searches for the user by ID in the database
  5. If the user does not exist, returns a 404 error
  6. If the user exists, generates a secure random password
  7. Hashes the new password with bcrypt
  8. Saves the new password in the database
  9. Sends an email with the newly generated password
  10. Returns the updated user data (excluding the password)
  11. Logs the action in the security history

Security

  • Requires authentication and management permissions (manager, admin, or dev role)
  • Randomly generated password is secure (minimum 8 characters)
  • Sent via email to ensure the actual user receives it
  • Requires proper authorization to perform this operation

Request

Responses

Password successfully reset

Response Headers