transition to postgresql for persistence layer
This commit is contained in:
+16
-12
@@ -17,12 +17,12 @@ const env: Record<string, string | undefined> =
|
||||
typeof process?.env !== "undefined"
|
||||
? process.env
|
||||
: import.meta && "env" in import.meta
|
||||
? (
|
||||
import.meta as ImportMeta & {
|
||||
env: Record<string, string | undefined>;
|
||||
}
|
||||
).env
|
||||
: {};
|
||||
? (
|
||||
import.meta as ImportMeta & {
|
||||
env: Record<string, string | undefined>;
|
||||
}
|
||||
).env
|
||||
: {};
|
||||
|
||||
if (!globalThis.crypto) {
|
||||
/**
|
||||
@@ -30,7 +30,7 @@ if (!globalThis.crypto) {
|
||||
*/
|
||||
Object.defineProperty(globalThis, "crypto", {
|
||||
value: await import("node:crypto").then(
|
||||
(crypto) => crypto.webcrypto as Crypto,
|
||||
(crypto) => crypto.webcrypto as Crypto
|
||||
),
|
||||
writable: false,
|
||||
configurable: true,
|
||||
@@ -40,7 +40,7 @@ if (!globalThis.crypto) {
|
||||
const authjsConfig = {
|
||||
basePath: "/api/auth",
|
||||
trustHost: Boolean(
|
||||
env.AUTH_TRUST_HOST ?? env.VERCEL ?? env.NODE_ENV !== "production",
|
||||
env.AUTH_TRUST_HOST ?? env.VERCEL ?? env.NODE_ENV !== "production"
|
||||
),
|
||||
// TODO: Replace secret {@see https://authjs.dev/reference/core#secret}
|
||||
secret: "MY_SECRET",
|
||||
@@ -54,7 +54,11 @@ const authjsConfig = {
|
||||
},
|
||||
async authorize() {
|
||||
// Add logic here to look up the user from the credentials supplied
|
||||
const user = { id: "1", name: "J Smith", email: "jsmith@example.com" };
|
||||
const user = {
|
||||
id: "019900bb-61b3-7333-b760-b27784dfe33b",
|
||||
name: "J Smith",
|
||||
email: "jsmith@example.com",
|
||||
};
|
||||
|
||||
// Any object returned will be saved in `user` property of the JWT
|
||||
// If you return null then an error will be displayed advising the user to check their details.
|
||||
@@ -70,7 +74,7 @@ const authjsConfig = {
|
||||
*/
|
||||
export async function getSession(
|
||||
req: Request,
|
||||
config: Omit<AuthConfig, "raw">,
|
||||
config: Omit<AuthConfig, "raw">
|
||||
): Promise<Session | null> {
|
||||
setEnvDefaults(process.env, config);
|
||||
const requestURL = new URL(req.url);
|
||||
@@ -79,12 +83,12 @@ export async function getSession(
|
||||
requestURL.protocol,
|
||||
req.headers,
|
||||
process.env,
|
||||
config,
|
||||
config
|
||||
);
|
||||
|
||||
const response = await Auth(
|
||||
new Request(url, { headers: { cookie: req.headers.get("cookie") ?? "" } }),
|
||||
config,
|
||||
config
|
||||
);
|
||||
|
||||
const { status = 200 } = response;
|
||||
|
||||
Reference in New Issue
Block a user