Skip to content

Commit

Permalink
chore(repo): Fix integration with async middleware updates (#4382)
Browse files Browse the repository at this point in the history
  • Loading branch information
BRKalow authored Oct 22, 2024
1 parent 58c99a5 commit 46dfb38
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .changeset/clean-fishes-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
6 changes: 3 additions & 3 deletions integration/tests/handshake.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1381,9 +1381,9 @@ const startAppWithOrganizationSyncOptions = async (clerkAPIUrl: string): Promise
export const middleware = (req, evt) => {
const orgSyncOptions = req.headers.get("x-organization-sync-options")
return clerkMiddleware((auth, req) => {
if (isProtectedRoute(req) && !auth().userId) {
auth().redirectToSignIn()
return clerkMiddleware(async (auth, req) => {
if (isProtectedRoute(req) && !(await auth()).userId) {
(await auth()).redirectToSignIn()
}
}, {
publishableKey: req.headers.get("x-publishable-key"),
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/hooks/useAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export const useAuth: UseAuth = (initialAuthState = {}) => {
};

export function useDerivedAuth(authObject: any): UseAuthReturn {
const { sessionId, userId, actor, orgId, orgSlug, orgRole, has, signOut, getToken } = authObject;
const { sessionId, userId, actor, orgId, orgSlug, orgRole, has, signOut, getToken } = authObject ?? {};

if (sessionId === undefined && userId === undefined) {
return {
Expand Down

0 comments on commit 46dfb38

Please sign in to comment.