-
Notifications
You must be signed in to change notification settings - Fork 118
Middlewares
Thomas Lynch edited this page Oct 2, 2024
·
5 revisions
-
useSession
- Initialise session from cookie -
useJWT
- Initialise session from jwt -
fetchSession
- Fetch the account from the database based on the session identifier -
checkSession
- Check that the users is logged in i.e the previous fetchSession returned a user -
onboardedMiddleware
- Check if the user set their role and/or default model credentials -
csrfMiddleware
- Makesreq.csrfToken()
available to put in pages/json responses for GETs, or checks the_csrf
body validity for POST/PUT/DELETE/etc -
setPermissions
- Set res.locals.permissions based on the current org/team context -
hasPerms
- Check if a single, or multiple (or/any) permissions are true -
checkSubscriptionPlan
- Check for a specific subscription plan -
checkSubscriptionBoolean
- Check if the subscription plan has a boolean set to true e.g.dataConnections
inPricingMatrix
-
checkSubscriptionLimit
- Check if a number usage e.g.users
(number of team members) is below the limit inPricingMatrix
-
checkResourceSlug
- Check if the :resourceSlug param (team id) is valid for the current user and setmatchingTeam
andmatchingOrg
locals -
checkResourceSlug
- Same thing but checks a query string -
setDefaultOrgAndTeam
- SetmatchingTeam
andmatchingOrg
locals based on thecurrentTeam
from the session account.
Note: all of these are keys under res.locals
e.g. account
-> res.locals.account
.
-
account
- The authed users account with some fields projected away set byfetchSession
-
stripe
- Thestripe
property from the account of the org owner in the current context, or the current account if not a route that has a team/org context set bycheckSubscription
-
data
- Temporary data that is passed to the page props bygetServerSideProps
in SSR'd pages, set in the controllers -
limits
- Limits based on the current subscription and team/org context set bycheckSubscription
-
matchingTeam
- Team of the current request context (note:_id
prop is renamed toid
) set bycheckResourceSlug
and similar -
matchingOrg
- Org of the current request context (note:_id
prop is renamed toid
) set bycheckResourceSlug
and similar -
permissions
- Permissions of the user in the current request context, set bysetPermissions