mirror of
https://github.com/better-auth/better-auth.git
synced 2026-05-23 07:18:56 -05:00
feat: export oAuthState for config use
This commit is contained in:
@@ -3,6 +3,7 @@ import { getSessionFromCtx } from "better-auth/api";
|
||||
import { generateRandomString, makeSignature } from "better-auth/crypto";
|
||||
import type { Verification } from "better-auth/db";
|
||||
import { APIError } from "better-call";
|
||||
import { oAuthState } from "./oauth";
|
||||
import type {
|
||||
OAuthAuthorizationQuery,
|
||||
OAuthConsent,
|
||||
@@ -131,6 +132,10 @@ export async function authorizeEndpoint(
|
||||
|
||||
// Check request
|
||||
const query: OAuthAuthorizationQuery = ctx.query;
|
||||
await oAuthState.set({
|
||||
query: query.toString(),
|
||||
});
|
||||
|
||||
if (!query.client_id) {
|
||||
throw ctx.redirect(
|
||||
getErrorURL(ctx, "invalid_client", "client_id is required"),
|
||||
|
||||
@@ -5,5 +5,5 @@ export {
|
||||
oauthProviderOpenIdConfigMetadata,
|
||||
oidcServerMetadata,
|
||||
} from "./metadata";
|
||||
export { oauthProvider } from "./oauth";
|
||||
export { getOAuthProviderState, oauthProvider } from "./oauth";
|
||||
export type * from "./types";
|
||||
|
||||
@@ -41,6 +41,7 @@ declare module "@better-auth/core" {
|
||||
export const oAuthState = defineRequestState<{ query?: string } | null>(
|
||||
() => null,
|
||||
);
|
||||
export const getOAuthProviderState = oAuthState.get;
|
||||
|
||||
/**
|
||||
* oAuth 2.1 provider plugin for Better Auth.
|
||||
|
||||
Reference in New Issue
Block a user