M1 (6): nobody creates an account for themselves

accounts.adminOnlyCreate (on): a staff collection without a create rule gets
"an admin, fully signed in" instead of Payload's "any logged-in user" — also the
project's own collection; a rule the project wrote stays.
accounts.firstUserRoute ('panel'): Payload's first-user route answers only for
the collection the panel logs in with. For any other empty auth collection it is
refused, unless that collection's own create rule lets an anonymous request in.
Checked and closed: an empty second staff collection, whose first visitor became
a staff admin (test/accountRulesOff.test.ts records the old behaviour, which
accounts: false / firstUserRoute: 'all' still give).
Doctor: open-signup (deep, info) names auth collections with open sign-up.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-25 00:39:12 +01:00
co-authored by Claude Fable 5.2
parent cd60b73685
commit c6fc0d21fe
10 changed files with 364 additions and 5 deletions
+8 -1
View File
@@ -5,6 +5,7 @@ import { readFileSync } from 'node:fs'
import type { DoctorStatus } from './types.js'
import { openSignUpCollections } from '../access/selfRegistration.js'
import { countPendingCookies } from '../consent/scanner/approval.js'
import { COOKIE_REVIEW_SLUG } from '../consent/scanner/collection.js'
import { secondFactorPassed, SETUP_FROM_FIELD } from '../security/totp/secondFactor.js'
@@ -61,7 +62,13 @@ export async function collectDoctorStatus(payload: BasePayload): Promise<DoctorS
/* the global cannot be read: unknown */
}
}
return { node: process.version, pendingCookies, plugin: pluginVersion(), turnstile, turnstileSecretFromEnv: secretFromEnv, usersSetupClosed, usersWithout2fa }
let openSignUp: null | string[] = null
try {
openSignUp = await openSignUpCollections(payload as never)
} catch {
openSignUp = null
}
return { node: process.version, openSignUp, pendingCookies, plugin: pluginVersion(), turnstile, turnstileSecretFromEnv: secretFromEnv, usersSetupClosed, usersWithout2fa }
}
export type DoctorEndpointOptions = {