fix(auth) : bind Sudloh sessions and stop OAuth redirect loops
This commit is contained in:
+5
-2
@@ -20,6 +20,7 @@ import { HttpError } from "@/lib/security/http";
|
||||
import { consumeRateLimit } from "@/lib/security/rate-limit";
|
||||
import { sendAuthEmail } from "./email";
|
||||
import { bindSudlohSession, validateSudlohSession } from "./sudloh";
|
||||
import { isSudlohCallback } from "./sudloh-callback";
|
||||
|
||||
function required(name: string): string {
|
||||
const value = process.env[name];
|
||||
@@ -65,9 +66,11 @@ function createAuth() {
|
||||
transaction: true,
|
||||
}),
|
||||
...(oidcOnly ? { databaseHooks: { session: { create: { after: async (
|
||||
session: { id: string; userId: string }, context: { path: string } | null,
|
||||
session: { id: string; userId: string },
|
||||
context: { path: string; params?: { id?: string } } | null,
|
||||
) => {
|
||||
if (context?.path.endsWith("/callback/sudloh")) await bindSudlohSession(session.userId, session.id);
|
||||
if (isSudlohCallback(context))
|
||||
await bindSudlohSession(session.userId, session.id);
|
||||
} } } } } : {}),
|
||||
baseURL: required("BETTER_AUTH_URL"),
|
||||
trustedOrigins: process.env.BETTER_AUTH_TRUSTED_ORIGINS
|
||||
|
||||
Reference in New Issue
Block a user