Skip to content

feat(provisioning_api): add endpoint to trigger password reset email for a user (#14411) - #64773

Open
tmmmemcee wants to merge 1 commit into
nextcloud:masterfrom
tmmmemcee:feat/14411-send-password-reset-email
Open

tmmmemcee wants to merge 1 commit into
nextcloud:masterfrom
tmmmemcee:feat/14411-send-password-reset-email

Conversation

@tmmmemcee

Copy link
Copy Markdown

Closes #14411

Summary

Adds an admin-only OCS endpoint that triggers the existing lost-password email flow for a user, so admins can force a password reset without knowing the current password. Mirrors the existing resendWelcomeMessage endpoint's admin/subadmin scoping pattern and reuses the real lost-password machinery (IVerificationToken + the core.ResetPassword mail template) — not a reinvented copy.

Backend

  • New route: POST /ocs/v2.php/cloud/users/{userId}/resetpassword
  • Guards (all mirroring LostController::sendEmail):
    • lost_password_link !== 'disabled' (returns 400)
    • User has an email address (returns 101 / "Email address not available")
    • Per-user rate limit: lostpasswordemail 5 / 30 min (same as self-service; returns 429)
    • #[PasswordConfirmationRequired] and #[NoAdminRequired] — admin/subadmin scoping identical to resendWelcomeMessage
  • Sends the real core.ResetPassword email with a freshly-issued token via the same flow as the self-service lost-password form, so the email looks identical to the user

Frontend

  • New "Send password reset email" action in the settings user-row menu (UserRow.vue), shown only when the account has an email, cloned from the "Resend welcome email" pattern
  • New Vuex store action sendPasswordResetMail in apps/settings/src/store/users.js posting to the new endpoint

openapi.json

openapi.json and openapi-full.json hand-updated to include the new endpoint (cloned from the welcome entry). CI regen on the next push may normalize formatting — happy to follow up if it produces a cleaner diff.

Test plan / verification

  • php -l clean on UsersController.php + routes.php
  • node --check clean on the new store action
  • OpenAPI JSON validates
  • ESLint, PHPUnit, psalm deferred to CI (not run locally — server-repo composer install / npm ci are multi-GB)

Credits / prior art

Implementation follows the maintainer scope laid out by @skjnldsv in the original issue (2019): an OCS provisioning API option + a Vue action in the user management UI.

…for a user

Adds an admin-only OCS endpoint POST /ocs/v2.php/cloud/users/{userId}/resetpassword that reuses the existing lost-password flow (IVerificationToken + core.ResetPassword mail template), respecting the same lost_password_link config and per-user rate limit as the self-service path. Mirrors resendWelcomeMessage's admin/subadmin scoping exactly.

Frontend: new 'Send password reset email' action in the settings user-row menu (only shown when the account has an email), backed by a new sendPasswordResetMail Vuex store action.

openapi.json + openapi-full.json hand-updated to include the new endpoint; CI regen may normalize formatting on next run.

Closes nextcloud#14411

Signed-off-by: Tim <tmmmemcee@gmail.com>
@tmmmemcee
tmmmemcee requested review from a team and provokateurin as code owners September 25, 2026 23:59
@tmmmemcee
tmmmemcee requested review from kristian-zendato, leftybournes, salmart-dev, skjnldsv and sorbaugh and removed request for a team September 25, 2026 23:59

@skjnldsv skjnldsv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please have a look at our ai policy and its requirements when opening pull requests
Thanks 😊

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trigger password reset email from user management

2 participants