fix: storeStateStrategy default to database if provided (#6619)

This commit is contained in:
Alex Yang
2025-12-09 08:52:45 +09:00
committed by github-actions[bot]
parent 2b058b0537
commit 49c6bb2e1f
2 changed files with 5 additions and 5 deletions

View File

@@ -170,7 +170,9 @@ export async function createAuthContext(
socialProviders: providers,
options,
oauthConfig: {
storeStateStrategy: options.account?.storeStateStrategy || "database",
storeStateStrategy:
options.account?.storeStateStrategy ||
(options.database ? "database" : "cookie"),
skipStateCookieCheck: !!options.account?.skipStateCookieCheck,
},
tables,

View File

@@ -27,8 +27,7 @@ export async function generateState(
const codeVerifier = generateRandomString(128);
const state = generateRandomString(32);
const storeStateStrategy =
c.context.oauthConfig?.storeStateStrategy || "cookie";
const storeStateStrategy = c.context.oauthConfig.storeStateStrategy;
const stateData = {
...(additionalData ? additionalData : {}),
@@ -99,8 +98,7 @@ export async function generateState(
export async function parseState(c: GenericEndpointContext) {
const state = c.query.state || c.body.state;
const storeStateStrategy =
c.context.oauthConfig.storeStateStrategy || "cookie";
const storeStateStrategy = c.context.oauthConfig.storeStateStrategy;
const stateDataSchema = z.looseObject({
callbackURL: z.string(),