Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save iamandrewluca/dc631d8af1e6697347ad50736b0430d3 to your computer and use it in GitHub Desktop.
Save iamandrewluca/dc631d8af1e6697347ad50736b0430d3 to your computer and use it in GitHub Desktop.
import { createAuth } from "@keystone-6/auth";
import { statelessSessions } from "@keystone-6/core/session";
import type { Lists } from ".keystone/types";
type Session = {
name: string;
createdAt: string;
};
type Join<T extends string, U extends string = T> =
| U
| (T extends any ? `${T} ${Join<Exclude<U, T>>}` : never);
export const { withAuth } = createAuth<Lists.User.TypeInfo<Session>>({
listKey: "User",
identityField: "email",
sessionData: "name createdAt" satisfies Join<keyof Session>,
secretField: "password",
});
export const session = statelessSessions<Session>({
maxAge: 60 * 60 * 24 * 30,
secret: "00000000000000000000000000000000",
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment