2FA Fix
This commit is contained in:
+13
-3
@@ -77,10 +77,20 @@ export const ipalKit = (options: IpalOptions): Plugin => {
|
||||
// node_modules). Avoids TS2307 without @ts-expect-error; the module
|
||||
// exists at runtime in projects that installed it.
|
||||
const pkg = '@clocklimited/payload-2fa'
|
||||
const { totpPlugin } = (await import(pkg)) as {
|
||||
totpPlugin: (opts: Record<string, unknown>) => Plugin
|
||||
const mod = (await import(pkg)) as {
|
||||
payloadTotp?: (opts: Record<string, unknown>) => Plugin
|
||||
totpPlugin?: (opts: Record<string, unknown>) => Plugin
|
||||
}
|
||||
config = await totpPlugin({
|
||||
// The package exports `payloadTotp`; older/other builds may use
|
||||
// `totpPlugin`. Accept either so a rename doesn't break us.
|
||||
const totp = mod.payloadTotp ?? mod.totpPlugin
|
||||
if (typeof totp !== 'function') {
|
||||
throw new Error(
|
||||
'expected export payloadTotp (or totpPlugin) to be a function — ' +
|
||||
'check the installed @clocklimited/payload-2fa version',
|
||||
)
|
||||
}
|
||||
config = await totp({
|
||||
collection: tf.collectionSlug ?? 'users',
|
||||
forceSetup: true, // ENFORCED — every user must set up TOTP; no opt-out
|
||||
totp: { issuer: tf.issuer },
|
||||
|
||||
Reference in New Issue
Block a user