Unified · Split
| @@ -171,38 +171,14 @@ export async function handleWorkOSCallback(context: WorkOSCallbackInput): Promis · 170 unmodified lines | |||
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | if (code && response.status >= 300 && response.status < 400) { | 173 | if (code && response.status >= 300 && response.status < 400) { |
| 174 | if (setCookieHeaders.length > 0) { | 174 | markCodeAsReplayed(code); |
| 175 | markCodeAsReplayed(code); | 175 | |
| 176 | 176 | if (isWorkosDebugEnabled()) { | |
| 177 | if (isWorkosDebugEnabled()) { | 177 | logWorkosAuth("callback.code-marked-used", { |
| 178 | logWorkosAuth("callback.code-marked-used", { | ||
| 179 | requestId, | ||
| 180 | code: redactAuthCode(code), | ||
| 181 | status: response.status, | ||
| 182 | setCookieCount: setCookieHeaders.length, | ||
| 183 | }); | ||
| 184 | } | ||
| 185 | } | ||
| 186 | else if (isWorkosDebugEnabled()) { | ||
| 187 | logWorkosAuth("callback.code-not-marked-used", { | ||
| 188 | requestId, | 178 | requestId, |
| 189 | code: redactAuthCode(code), | 179 | code: redactAuthCode(code), |
| 190 | status: response.status, | 180 | status: response.status, |
| 191 | reason: "missing-set-cookie", | 181 | setCookieCount: setCookieHeaders.length, |
| 192 | }); | ||
| 193 | } | ||
| 194 | |||
| 195 | if (setCookieHeaders.length === 0) { | ||
| 196 | return new Response(JSON.stringify({ | ||
| 197 | error: { | ||
| 198 | message: "Authentication did not set a session cookie", | ||
| 199 | description: "Sign-in completed but the callback response did not include Set-Cookie.", | ||
| 200 | }, | ||
| 201 | }), { | ||
| 202 | status: 500, | ||
| 203 | headers: { | ||
| 204 | "Content-Type": "application/json", | ||
| 205 | }, | ||
| 206 | }); | 182 | }); |
| 207 | } | 183 | } |
| 208 | 184 | ||