perf: use getSlimServerSession for session retrieval (#8308)
* perf: use getSlimServerSession for session retrieval Creates a new `getSlimServerSession` method and replaces all calls to `getServerSession`. The new method is much faster than `getServerSession` with it not requiring the NextAuth options object which includes a number of additional packages. Additionally introduces a primitive in-memory cache for slim sessions. * fix: account for seconds in token.exp * Reverts diffs * Replaces getServerSession with slimmer version * Update disable.ts --------- Co-authored-by: Peer Richelsen <[email protected]> Co-authored-by: Keith Williams <[email protected]> Co-authored-by: zomars <[email protected]>
This commit is contained in:
3 files changed
+97
-14
No files matched your search
Vendored
+14
-1
@@ -1,4 +1,4 @@
|
||||
import type { User as PrismaUser } from "@prisma/client";
|
||||
import type { User as PrismaUser, UserPermissionRole } from "@prisma/client";
|
||||
import type { DefaultUser } from "next-auth";
|
||||
|
||||
declare module "next-auth" {
|
||||
@@ -9,6 +9,7 @@ declare module "next-auth" {
|
||||
hasValidLicense: boolean;
|
||||
user: User;
|
||||
}
|
||||
|
||||
interface User extends Omit<DefaultUser, "id"> {
|
||||
id: PrismaUser["id"];
|
||||
emailVerified?: PrismaUser["emailVerified"];
|
||||
@@ -19,3 +20,15 @@ declare module "next-auth" {
|
||||
role?: PrismaUser["role"] | "INACTIVE_ADMIN";
|
||||
}
|
||||
}
|
||||
|
||||
declare module "next-auth/jwt" {
|
||||
interface JWT {
|
||||
id?: string | number;
|
||||
name?: string | null;
|
||||
username?: string | null;
|
||||
email?: string | null;
|
||||
role?: UserPermissionRole | "INACTIVE_ADMIN" | null;
|
||||
impersonatedByUID?: number | null;
|
||||
belongsToActiveTeam?: boolean;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user