[]previous and next page

signIn

Signs a visitor in: gives the session a new id first, then stores values in it.

Signs a visitor in: gives the session a new id first, then stores values in it. The id that came with the request (planted by an attacker before the sign-in, if it was) stops working at once, so session fixation is closed by construction. Data the session held before (an anonymous cart) is kept. Prefer it to calling session.set("userId", …) yourself.

Import#

ts
import { signIn } from "@shadow-js/dusk/server";

Signature#

ts
function signIn(session: Session, values: Readonly<Record<string, unknown>>): void

Parameters#

Name Description
session The session of the request (await sessions.get(event)).
values What identifies the user, for example { userId: user.id }.

Examples#

ts
const session = await sessions.get(event);
signIn(session, { userId: user.id });