Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/core/lib/assert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ export function assertConfig(
if (!req.host) return "NEXTAUTH_URL"

let hasCredentials, hasEmail
let hasTwitterProvider

options.providers.forEach(({ type }) => {
if (type === "credentials") hasCredentials = true
else if (type === "email") hasEmail = true
})
for (const provider of options.providers) {
if (provider.type === "credentials") hasCredentials = true
else if (provider.type === "email") hasEmail = true
else if (provider.id === "twitter") hasTwitterProvider = true
}

if (hasCredentials) {
const dbStrategy = options.session?.strategy === "database"
Expand All @@ -75,4 +77,8 @@ export function assertConfig(
if (hasEmail && !options.adapter) {
return new MissingAdapter("E-mail login requires an adapter.")
}

if (hasTwitterProvider) {
return "TWITTER_OAUTH_2_BETA"
}
}
2 changes: 1 addition & 1 deletion src/lib/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function hasErrorProperty(
return !!(x as any)?.error
}

export type WarningCode = "NEXTAUTH_URL" | "NO_SECRET"
export type WarningCode = "NEXTAUTH_URL" | "NO_SECRET" | "TWITTER_OAUTH_2_BETA"

/**
* Override any of the methods, and the rest will use the default logger.
Expand Down
7 changes: 1 addition & 6 deletions src/providers/twitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,10 @@ export interface TwitterProfile {
}
}

let warned = false
export default function Twitter<
P extends Record<string, any> = TwitterLegacyProfile | TwitterProfile
>(options: OAuthUserConfig<P>): OAuthConfig<P> {
if (!warned && options.version === "2.0") {
warned = true
console.warn(
"Opted-in to Twitter OAuth 2.0. See the docs https://next-auth.js.org/providers/twitter#oauth-2"
)
if (options.version === "2.0") {
return {
id: "twitter",
name: "Twitter",
Expand Down