Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

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

Deno-powered framework for building business web apps
Go to Latest
function getUserBySession
import { getUserBySession } from "https://deno.land/x/netzo@0.4.10/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