import { getUserBySession } from "https://deno.land/x/netzo@0.2.94/plugins/portals/utils/db.ts";
Gets the user with the given session ID from the database. The first attempt
is done with eventual consistency. If that returns null
, the second
attempt is done with strong consistency. This is done for performance
reasons, as this function is called in every route request for checking
whether the session user is signed in.
Examples
Example 1
Example 1
import { getUserBySession } from "netzo/plugins/portals/utils/db.ts";
const user = await getUserBySession("xxx");
user?.login; // Returns "jack"
user?.sessionId; // Returns "xxx"
user?.role; // Returns "admin"