Unified · Split
| @@ -171,38 +171,14 @@ export async function handleWorkOSCallback(context: WorkOSCallbackInput): Promis · 170 unmodified lines | ||
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | if (code && response.status >= 300 && response.status < 400) { |
| 174 | − if (setCookieHeaders.length > 0) { | |
| 175 | − markCodeAsReplayed(code); | |
| 176 | − | |
| 177 | − if (isWorkosDebugEnabled()) { | |
| 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", { | |
| 174 | + markCodeAsReplayed(code); | |
| 175 | + | |
| 176 | + if (isWorkosDebugEnabled()) { | |
| 177 | + logWorkosAuth("callback.code-marked-used", { | |
| 188 | 178 | requestId, |
| 189 | 179 | code: redactAuthCode(code), |
| 190 | 180 | status: response.status, |
| 191 | − reason: "missing-set-cookie", | |
| 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 | − }, | |
| 181 | + setCookieCount: setCookieHeaders.length, | |
| 206 | 182 | }); |
| 207 | 183 | } |
| 208 | 184 | |