-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(user): enforce session check (#646)
- Loading branch information
1 parent
d12f14c
commit bc22242
Showing
9 changed files
with
100 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/user/src/supertokens/recipes/config/session/getSession.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import type { FastifyInstance } from "fastify"; | ||
import type { RecipeInterface } from "supertokens-node/recipe/session/types"; | ||
|
||
const getSession = ( | ||
originalImplementation: RecipeInterface, | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
fastify: FastifyInstance | ||
): RecipeInterface["getSession"] => { | ||
return async (input) => { | ||
if (originalImplementation.createNewSession === undefined) { | ||
throw new Error("Should never come here"); | ||
} | ||
|
||
input.options = { | ||
checkDatabase: | ||
fastify.config.user.supertokens.checkSessionInDatabase ?? true, | ||
...input.options, | ||
}; | ||
|
||
const originalResponse = await originalImplementation.getSession(input); | ||
|
||
return originalResponse; | ||
}; | ||
}; | ||
|
||
export default getSession; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters