Skip to content

Commit 8927fc7

Browse files
committed
Remove @ts-expect-error
1 parent 17c8480 commit 8927fc7

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

packages/backend/src/tokens/authStatus.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export type SignedInState = {
2727
afterSignInUrl: string;
2828
afterSignUpUrl: string;
2929
isSignedIn: true;
30-
toAuth: (opts?: PendingSessionOptions) => SignedInAuthObject;
30+
toAuth: (opts?: PendingSessionOptions) => SignedInAuthObject | SignedOutAuthObject;
3131
headers: Headers;
3232
token: string;
3333
};
@@ -99,7 +99,6 @@ export function signedIn(
9999
afterSignInUrl: authenticateContext.afterSignInUrl || '',
100100
afterSignUpUrl: authenticateContext.afterSignUpUrl || '',
101101
isSignedIn: true,
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.
103102
toAuth: ({ treatPendingAsSignedOut = true } = {}) => {
104103
if (treatPendingAsSignedOut && authObject.sessionStatus === 'pending') {
105104
return signedOutAuthObject(undefined, authObject.sessionStatus);

packages/backend/src/tokens/request.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -463,13 +463,13 @@ export async function authenticateRequest(
463463
authenticateContext.sessionTokenInCookie!,
464464
);
465465

466+
const authObject = signedInRequestState.toAuth();
466467
// Org sync if necessary
467-
const handshakeRequestState = handleMaybeOrganizationSyncHandshake(
468-
authenticateContext,
469-
signedInRequestState.toAuth(),
470-
);
471-
if (handshakeRequestState) {
472-
return handshakeRequestState;
468+
if (authObject.userId) {
469+
const handshakeRequestState = handleMaybeOrganizationSyncHandshake(authenticateContext, authObject);
470+
if (handshakeRequestState) {
471+
return handshakeRequestState;
472+
}
473473
}
474474

475475
return signedInRequestState;

0 commit comments

Comments
 (0)