Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/netzo/plugins/auth/utils/db.ts>getUserBySession

Full-stack Deno framework for building business web apps like internal tools, dashboards, admin panels and automated workflows.
Go to Latest
function getUserBySession
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

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"

Parameters

sessionId: string