Skip to content

Commit 3a2bd6c

Browse files
committed
Add changeset
1 parent a7343bb commit 3a2bd6c

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

.changeset/flat-papers-begin.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@clerk/backend': minor
3+
'@clerk/express': minor
4+
---
5+
6+
Introduce `treatPendingAsSignedOut` option to `getAuth`
7+
8+
```ts
9+
// Both `active` and `pending` sessions will be treated as authenticated when `treatPendingAsSignedOut` is false
10+
const { userId } = getAuth(req, locals, { treatPendingAsSignedOut: false })
11+
```
12+
13+
```ts
14+
// `pending` sessions will be treated as signed-out by default
15+
const { userId } = getAuth(req, locals)
16+
```

packages/backend/src/tokens/authStatus.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export function signedIn(
9999
afterSignInUrl: authenticateContext.afterSignInUrl || '',
100100
after#Url: authenticateContext.after#Url || '',
101101
isSignedIn: true,
102-
// @ts-expect-error Dynamically return `SignedOutAuthObject` based on options
102+
// @ts-expect-error The return type is intentionally overridden here to support consumer-facing logic that treats pending sessions as signed out. This override does not affect internal session management like handshake flows.
103103
toAuth: ({ treatPendingAsSignedOut = true } = {}) => {
104104
if (treatPendingAsSignedOut && authObject.sessionStatus === 'pending') {
105105
return signedOutAuthObject(undefined, authObject.sessionStatus);

packages/express/src/getAuth.ts

-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,5 @@ export const getAuth = (req: ExpressRequest, options?: GetAuthOptions): AuthObje
2020
throw new Error(middlewareRequired('getAuth'));
2121
}
2222

23-
// this has to receive an option
2423
return req.auth(options);
2524
};

0 commit comments

Comments
 (0)