2FA fixed
This commit is contained in:
+8
-7
@@ -78,10 +78,11 @@ export const ipalKit = (options: IpalOptions): Plugin => {
|
||||
let totp: TotpPluginFactory | undefined = tf.plugin
|
||||
|
||||
if (!totp) {
|
||||
// Fallback: dynamic import. Variable specifier dodges the plugin's own
|
||||
// TS2307, but Next may NOT trace it into the server bundle — projects
|
||||
// using this path MUST add '@clocklimited/payload-2fa' to
|
||||
// serverExternalPackages in next.config (see docs/security.md).
|
||||
// Fallback: dynamic import, resolvable because the package is an optional
|
||||
// peer. Variable specifier dodges the plugin's own TS2307. Works only
|
||||
// outside Next (payload CLI): webpack turns it into an empty context, and
|
||||
// serverExternalPackages fails on the package's own .css imports — in
|
||||
// Next the project MUST inject `plugin` (see docs/security.md).
|
||||
try {
|
||||
const pkg = '@clocklimited/payload-2fa'
|
||||
const mod = (await import(pkg)) as {
|
||||
@@ -92,9 +93,9 @@ export const ipalKit = (options: IpalOptions): Plugin => {
|
||||
} catch (err) {
|
||||
throw new Error(
|
||||
'[ipal] 2FA is enforced but @clocklimited/payload-2fa could not be loaded. ' +
|
||||
'Best fix — inject it: `import { payloadTotp } from "@clocklimited/payload-2fa"` ' +
|
||||
'then `twoFactor: { issuer, plugin: payloadTotp }`. Or install it AND add ' +
|
||||
"'@clocklimited/payload-2fa' to serverExternalPackages in next.config. Or set " +
|
||||
'Inject it (required in Next): `import { payloadTotp } from "@clocklimited/payload-2fa"` ' +
|
||||
'then `twoFactor: { issuer, plugin: payloadTotp }`. Adding it to ' +
|
||||
'serverExternalPackages does NOT help (the package imports .css). Or set ' +
|
||||
`twoFactor: false to opt out (discouraged). Original error: ${String(err)}`,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user