Skip to content

added OTP support for password recovery endpoints - #13781

Merged
Meldiron merged 4 commits into
appwrite:mainfrom
imtia33:feat/add-otp-support-for-password-recovery
Sep 21, 2026
Merged

Meldiron merged 4 commits into
appwrite:mainfrom
imtia33:feat/add-otp-support-for-password-recovery

Conversation

@imtia33

@imtia33 imtia33 commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds support for OTP (One-Time Password) based password recovery alongside the existing magic link password recovery flow:

  • Token & Email Template Constants: Added TOKEN_TYPE_RECOVERY_OTP (11) in app/init/constants.php and registered MAIL_TEMPLATE_OTP_RECOVERY (otp-recovery).
  • API Endpoints: Registered POST /v1/account/recovery/otp (createRecoveryOTP) and PUT /v1/account/recovery/otp (updateRecoveryOTP) endpoints under the account namespace in app/controllers/api/account.php.
  • Worker Integration: Added TOKEN_TYPE_RECOVERY_OTP to src/Appwrite/Platform/Workers/Deletes.php so expired recovery OTP tokens are automatically purged by background deletion workers.
  • Email Templates & Translations: Updated email template resolvers in Project and Console modules (Get.php), added otpRecovery to templates.php, and added localization keys in en.json.
  • Documentation: Created reference documentation for create-recovery-otp.md and update-recovery-otp.md.

Test Plan

  • Unit Tests: Added testTokenVerifyRecoveryOtp to tests/unit/Utopia/Database/Documents/UserTest.php testing TOKEN_TYPE_RECOVERY_OTP verification, type isolation against verification/login OTPs, and expiry handling. Verified all 11 unit tests pass (11 tests, 91 assertions).
  • E2E Tests: Added testCreateRecoveryOTP and testUpdateRecoveryOTP to tests/e2e/Services/Account/AccountCustomClientTest.php covering OTP generation, secret verification, password update, and error cases (e.g., invalid tokens).
  • Template Schema Tests: Added 'otpRecovery' to exhaustive template list validation in tests/e2e/Services/Project/TemplatesBase.php.

Related PRs and Issues

  • N/A

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

@greptile-apps

greptile-apps Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge, with no outstanding correctness or repository-rule findings.

Summary

Adds OTP-based password recovery alongside the existing recovery-link flow.

  • Registers endpoints for creating and consuming recovery OTPs.
  • Adds OTP recovery email templates, localization, customization support, and documentation.
  • Includes expired-token cleanup and end-to-end coverage for delivery, reset, token isolation, and single use.
  • The only change since the previous review removes a redundant conditional while building an email for an already-confirmed deliverable profile.

Reviews (4) · Last reviewed commit: "fix: drop redundant deliverable ternary ..."

Comment thread app/controllers/api/account.php Resolved
@Meldiron
Meldiron merged commit 3f1732e into appwrite:main Sep 21, 2026
49 checks passed
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.

2 participants