import { getUserBySession } from "https://deno.land/x/netzo@0.4.49/plugins/auth/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 "../../../../auth/utils/db.ts";
const user = await getUserBySession("xxx");
user?.authId; // Returns "auth0|xxx"
user?.sessionId; // Returns "xxx"
user?.roles; // Returns ["admin"]
user?.provider; // Returns "github"