Skip to content

Commit

Permalink
update user when refreshing (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmatheson authored Jul 9, 2024
1 parent 8e54010 commit 79cf806
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
11 changes: 7 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"@workos-inc/node": "^6.8.0",
"@workos-inc/node": "^7.12.0",
"iron-session": "^8.0.1",
"jose": "^5.2.3",
"path-to-regexp": "^6.2.2"
Expand Down
6 changes: 3 additions & 3 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ async function updateSession(request: NextRequest, debug: boolean, middlewareAut
if (debug) console.log('Session invalid. Attempting refresh', session.refreshToken);

// If the session is invalid (i.e. the access token has expired) attempt to re-authenticate with the refresh token
const { accessToken, refreshToken } = await workos.userManagement.authenticateWithRefreshToken({
const { accessToken, refreshToken, user, impersonator } = await workos.userManagement.authenticateWithRefreshToken({
clientId: WORKOS_CLIENT_ID,
refreshToken: session.refreshToken,
});
Expand All @@ -96,8 +96,8 @@ async function updateSession(request: NextRequest, debug: boolean, middlewareAut
const encryptedSession = await encryptSession({
accessToken,
refreshToken,
user: session.user,
impersonator: session.impersonator,
user,
impersonator,
});

newRequestHeaders.set(sessionHeaderName, encryptedSession);
Expand Down
2 changes: 1 addition & 1 deletion src/workos.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import WorkOS from '@workos-inc/node';
import { WorkOS } from '@workos-inc/node';
import { WORKOS_API_HOSTNAME, WORKOS_API_HTTPS, WORKOS_API_KEY, WORKOS_API_PORT } from './env-variables.js';


Expand Down

0 comments on commit 79cf806

Please sign in to comment.