Skip to content
On this page

Function: checkSignInRule()

TypeScript
function checkSignInRule(session: SessionPayload, options: SignInRuleOptions): Promise<SignInRuleCheck>;

Defined in: me-client/src/server.ts:710 (opens in a new tab)

Apply your project's "who can sign in" rule to a session you have already verified, for a site whose own session replaces the token: checkOcToken and verifyOcToken check the token, not the rule. It reads the rule with the same one-minute cache and ten-minute stand-in as withOcAuth, and refuses rather than lets in when no rule could be read.

session is the object verifyOcToken, checkOcToken, getOcSession or an adapter (req.ocSession) returned, as is. Anything else throws, a copy or claims read back from your own store included: apply the rule in the route that starts your session, where you hold the verified one. It also throws on a missing rule or an option it does not read.

const session = await verifyOcToken(token, { audience: 'https://your-site.example (opens in a new tab)' }); if (!session) return res.status(401).json({ ok: false }); const checked = await checkSignInRule(session, { projectKey: process.env.OC_PROJECT_KEY! }); if (!checked.ok) return res.status(checked.status).json(checked.body);

ParametersLink to this section

ParameterType
sessionSessionPayload
optionsSignInRuleOptions

ReturnsLink to this section

Promise<SignInRuleCheck>