Skip to content

Commit

Permalink
Fix some return types (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Asjes authored Oct 4, 2024
1 parent 7d71910 commit 5fd855c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
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": "7.26.0",
"@workos-inc/node": "7.27.4",
"iron-session": "^8.0.1",
"jose": "^5.2.3",
"path-to-regexp": "^6.2.2"
Expand Down
1 change: 1 addition & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface NoUserInfo {
sessionId?: undefined;
organizationId?: undefined;
role?: undefined;
permissions?: undefined;
impersonator?: undefined;
accessToken?: undefined;
}
Expand Down
10 changes: 5 additions & 5 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,12 @@ async function refreshSession({

return {
sessionId,
user: session.user,
user,
organizationId,
role,
permissions,
impersonator: session.impersonator,
accessToken: session.accessToken,
impersonator,
accessToken,
};
}

Expand Down Expand Up @@ -278,12 +278,12 @@ async function getSessionFromCookie(response?: NextResponse) {
/**
* Retrieves the session from the cookie. Meant for use in the middleware, for client side use `withAuth` instead.
*
* @returns Session | undefined
* @returns UserInfo | NoUserInfo
*/
async function getSession(response?: NextResponse) {
const session = await getSessionFromCookie(response);

if (!session) return;
if (!session) return { user: null };

if (await verifyAccessToken(session.accessToken)) {
const { sid: sessionId, org_id: organizationId, role, permissions } = decodeJwt<AccessToken>(session.accessToken);
Expand Down

0 comments on commit 5fd855c

Please sign in to comment.