Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make missing secret an error #3143

Merged
merged 16 commits into from
Nov 15, 2021
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
refactor: optimize assertConfig
balazsorban44 committed Nov 15, 2021
commit 898c6843a8145c9bfb19a92a9dd809eb0f2d73ee
16 changes: 11 additions & 5 deletions src/core/lib/assert.ts
Original file line number Diff line number Diff line change
@@ -51,21 +51,27 @@ export function assertConfig(
})

if (hasCredentials) {
if (options.session?.strategy === "database" || options.adapter) {
const dbStrategy = options.session?.strategy === "database"
const onlyCredentials = !options.providers.some(
(p) => p.type !== "credentials"
)
if (dbStrategy || onlyCredentials) {
return new UnsupportedStrategy(
"Signin in with credentials only supported if JWT strategy is enabled"
)
}
if (
options.providers.every((p) => p.type !== "credentials" || p.authorize)
) {

const credentialsNoAuthorize = options.providers.some(
(p) => p.type === "credentials" && !p.authorize
)
if (credentialsNoAuthorize) {
return new MissingAuthorize(
"Must define an authorize() handler to use credentials authentication provider"
)
}
}

if (!options.adapter && hasEmail) {
if (hasEmail && !options.adapter) {
return new MissingAdapter("E-mail login requires an adapter.")
}
}