TASK22224: nextauth notify try-catch micro-refactor

This commit is contained in:
2026-03-24 06:18:35 +00:00
parent fe394f3fa8
commit 7c0dc30b1a
2 changed files with 42 additions and 4 deletions
+36
View File
@@ -689,3 +689,39 @@ Validation:
Follow-ups:
- Optional further hygiene pass can target remaining oversized commented historical sections in non-sensitive handlers.
---
### CL-018: TASK22224 nextauth notify micro-refactor
date: 2026-03-24
author: Cline
scope: `pages/api/auth/[...nextauth].js`
type: change
rationale: Execute the explicitly approved auth micro-slice by replacing inline promise `.catch(...)` with explicit `try/catch` while preserving existing auth behavior.
impact: Auth-sensitive non-functional refactor only; keeps current sign-in flow, template/locale routing, and error-handling semantics unchanged.
status: completed
Summary:
- `pages/api/auth/[...nextauth].js`
- replaced:
- `await notifyClient.sendEmail(...).catch((error) => consoleLogger(error))`
- with explicit:
- `try { await notifyClient.sendEmail(...) } catch (error) { consoleLogger(error) }`
- preserved behavior contracts:
- Notify failures are still logged and do not throw through auth handler
- no changes to callback URL construction, locale/template selection, NextAuth options, session/cookies/pages config
Validation:
- `node tests/phase21/api-contract-slice1.test.cjs` -> pass
- helper: 4/4
- file-handler: 53/53
- email-handler: 12/12
- endpoint-handler: 152/152
- documents-handler: 3/3
Follow-ups:
- Optional future auth hygiene (separate guarded slice): replace verbose auth `console.log` diagnostics with structured logger usage once production logging requirements are confirmed.
+6 -4
View File
@@ -139,8 +139,8 @@ const authOptions = (req, res) => {
process.env.NOTIFY_API_KEY
);
await notifyClient
.sendEmail(
try {
await notifyClient.sendEmail(
effectiveLocale === "cy"
? templateIdcy
: templateId,
@@ -149,8 +149,10 @@ const authOptions = (req, res) => {
personalisation,
reference
}
)
.catch((error) => consoleLogger(error));
);
} catch (error) {
consoleLogger(error);
}
}
})
],