mirror of
https://github.com/better-auth/better-auth.git
synced 2026-05-30 19:06:47 -05:00
fix(generic-oauth): remove type from config
This commit is contained in:
@@ -24,11 +24,6 @@ interface GenericOAuthConfig {
|
||||
* If provided, the authorization and token endpoints will be fetched from this URL.
|
||||
*/
|
||||
discoveryUrl?: string;
|
||||
/**
|
||||
* Type of OAuth flow.
|
||||
* @default "oauth2"
|
||||
*/
|
||||
type?: "oauth2" | "oidc";
|
||||
/**
|
||||
* URL for the authorization endpoint.
|
||||
* Optional if using discoveryUrl.
|
||||
@@ -116,10 +111,9 @@ interface GenericOAuthOptions {
|
||||
|
||||
async function getUserInfo(
|
||||
tokens: OAuth2Tokens,
|
||||
type: "oauth2" | "oidc",
|
||||
finalUserInfoUrl: string | undefined,
|
||||
) {
|
||||
if (type === "oidc" && tokens.idToken) {
|
||||
if (tokens.idToken) {
|
||||
const decoded = parseJWT(tokens.idToken) as {
|
||||
payload: {
|
||||
sub: string;
|
||||
@@ -145,6 +139,7 @@ async function getUserInfo(
|
||||
sub?: string;
|
||||
name: string;
|
||||
email_verified: boolean;
|
||||
picture: string;
|
||||
}>(finalUserInfoUrl, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
@@ -155,6 +150,7 @@ async function getUserInfo(
|
||||
id: userInfo.data?.sub,
|
||||
emailVerified: userInfo.data?.email_verified,
|
||||
email: userInfo.data?.email,
|
||||
image: userInfo.data?.picture,
|
||||
...userInfo.data,
|
||||
};
|
||||
}
|
||||
@@ -418,11 +414,7 @@ export const genericOAuth = (options: GenericOAuthOptions) => {
|
||||
const userInfo = (
|
||||
provider.getUserInfo
|
||||
? await provider.getUserInfo(tokens)
|
||||
: await getUserInfo(
|
||||
tokens,
|
||||
provider.type || "oauth2",
|
||||
finalUserInfoUrl,
|
||||
)
|
||||
: await getUserInfo(tokens, finalUserInfoUrl)
|
||||
) as User | null;
|
||||
|
||||
if (!userInfo?.email) {
|
||||
|
||||
Reference in New Issue
Block a user