{"record":{"id":"b4d5ffa6ad1739a8","repo":"moeru-ai/airi","slug":"requestpasswordreset-failed","errorCode":null,"errorMessage":"requestPasswordReset failed","messagePattern":"requestPasswordReset failed","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/stage-pages/src/pages/settings/account/account-settings-page.vue","lineNumber":319,"sourceCode":"\n  try {\n    // NOTICE:\n    // `redirectTo` MUST live on the API server origin, not on the current\n    // browser origin. This page is shared with apps/stage-tamagotchi,\n    // whose Electron renderer loads from `file://` — `window.location.origin`\n    // would put a `file://` URL into the reset email and break the flow\n    // for any user who clicks from their inbox. The auth UI is hosted at\n    // `${SERVER_URL}/auth/reset-password` and reachable from the public\n    // internet.\n    // Source: PR #1753 review (chatgpt-codex-connector P1).\n    //\n    // The reset-password endpoint also covers the initial-set case — it\n    // creates a credential row when none exists, see\n    // node_modules/better-auth/dist/api/routes/password.mjs L152-158.\n    const redirectTo = new URL('/auth/reset-password', SERVER_URL).toString()\n    const { error } = await authClient.requestPasswordReset({ email, redirectTo })\n    if (error)\n      throw new Error(error.message ?? 'requestPasswordReset failed')\n    setPasswordSuccess.value = t('settings.pages.account.security.message.setLinkSent', { email })\n    trackPasswordResetRequested()\n  }\n  catch (error) {\n    setPasswordError.value = errorMessageFrom(error) ?? t('settings.pages.account.security.error.setLinkFailed')\n  }\n  finally {\n    setPasswordLoading.value = false\n  }\n}\n\n// ---- Delete account ----\n//\n// Two-step flow:\n// (1) Click \"Delete account\" -> open a reka-ui Dialog with a focus-trap and\n//     overlay so the destructive action is unambiguously modal. Inside the\n//     dialog the user retypes their email; we only enable the submit button\n//     when the entered value matches `userEmail` exactly. This is the same","sourceCodeStart":301,"sourceCodeEnd":337,"githubUrl":"https://github.com/moeru-ai/airi/blob/677329427f32468c74b17f3ec47eeca4e05bec65/packages/stage-pages/src/pages/settings/account/account-settings-page.vue#L301-L337","documentation":"Wraps authClient.requestPasswordReset({ email, redirectTo }); the literal fires only when better-auth's error carries no message. The endpoint also covers initial credential set (it creates a credential row when none exists), and redirectTo must be the hosted /auth/reset-password page because a file:// URL would break the emailed link.","triggerScenarios":"Auth server email/SMTP sender misconfigured so the reset mail fails; rate limiting after repeated requests; invalid email format; SERVER_URL wrong so redirectTo is invalid.","commonSituations":"Dev auth server without SMTP env vars; users requesting multiple resets in a row; running the UI from file:// where the redirect URL cannot work.","solutions":["Check the auth server's SMTP/email env configuration — most reset failures are send-side.","Log error.status/code; 429 means wait before retrying.","Confirm SERVER_URL is the public auth origin so redirectTo is valid.","Validate the email format client-side before sending."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (!/^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$/.test(email)) {\n  setPasswordError.value = 'Enter a valid email address'\n  return\n}","typeGuard":null,"tryCatchPattern":"catch (error) {\n  if ((error as { status?: number })?.status === 429)\n    setPasswordError.value = 'Too many requests — try again later'\n  else\n    setPasswordError.value = errorMessageFrom(error) ?? t('settings.pages.account.security.error.setLinkFailed')\n}","preventionTips":["Verify SMTP env configuration before enabling the reset flow.","Rate-limit the request button client-side.","Keep redirectTo on the hosted auth origin, never a file:// URL."],"tags":["auth","better-auth","password-reset","email"],"backgroundTag":"auth-api-error","analyzedSha":"677329427f32468c74b17f3ec47eeca4e05bec65","analyzedAt":"2026-08-18T17:29:58.153Z","contentChangedAt":"2026-08-18T17:29:58.153Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}