Skip to content
Directory
GitHub Star
Evidence, tags & source code

Account Recovery for a Personal Agent: More Than Sending a Reset Email ​

Suppose my personal research tool later admits a few authorized users. When someone forgets a password, administrators should not edit database passwords directly. Recovery is a time-limited, authorized collaboration between the authentication system and the mail service.

Separate recovery entry from sending ​

Use the same visible response for existing and nonexistent accounts to avoid revealing registration status. Rate-limit reset requests and new-password submissions separately, with shared limits across instances. Deliver only to a verified address obtained from the account system. Observable response time also matters: identical text is insufficient if timing reveals account existence.

Build the public origin and fixed reset path from trusted server configuration, not arbitrary Host headers or user-supplied URLs. Staging links return to staging, production links to production.

Reuse mature token and password handling ​

The Better Auth email/password documentation provides a reset callback and an option to revoke old sessions. This configuration shape depends on the application's mail adapter and actual framework version; it is not a standalone runnable application:

js
const authOptions = {
  emailAndPassword: {
    enabled: true,
    revokeSessionsOnPasswordReset: true,
    sendResetPassword: async ({ user, url }) => {
      // The application supplies a protected delivery adapter.
      await enqueueRecoveryEmail({ to: user.email, url })
    }
  }
}

The callback should finish secure enqueueing promptly rather than wait for actual mail delivery; still test observable timing differences between existing and nonexistent accounts. Queues and logs must not expose full reset URLs. Use the library to issue, expire and consume reset tokens once. Verify transaction support in the configured storage adapter: the library documents differences in failure atomicity between token consumption, password updates and session revocation across storage configurations. One configuration flag is not a universal security guarantee.

Acceptance paths ​

Synthetic testExpected behavior
Existing and nonexistent emailPublic response does not reveal the distinction
Expired, spent or invalid tokenReject reset without affecting other accounts
Valid new passwordOld password fails; new password works
Two existing sessionsVerify configured revocation on subsequent requests
Sending failure and delaySafe response, bounded retries, clear expiry window

Account reset and background research are distinct facts. Whether existing schedules and pending notifications stop depends on actual authorization and account state. Do not rerun research by default or continue allowing revoked credentials into the application.

This example does not qualify an existing Open ETF Agent password recovery implementation. Optional identity integration, delivery and observability can evolve under the application roadmap. See email delivery for the distinction between acceptance and final receipt.

Engineering notes, evidence and boundaries. · Contact: hpoenixf@foxmail.com · WeChat: hpoenixf0510