chore: Cherry-pick FormValidation migration + background user import onto develop - #537
Merged
Merged
Conversation
Replaces the deprecated `set_rules`/`set_message`/`run()` calls in admin account creation, social sign-on data capture, MFA device setup and MFA question setup with `buildValidator()`. Where the old code relied on `trim` being written back into `$_POST`, the success paths now read `getValidatedData()`. Forced `fv_*` message overrides are dropped where they matched the validator's defaults. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> (cherry picked from commit 5d25d8a)
Replaces `get_instance()->lang->load(...)` with `Factory::service('Translation')->load(...)`, which works outside a CodeIgniter request.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
(cherry picked from commit 63bca4f)
…ort rules The password rule read `group_id` through the FormValidation service's CodeIgniter `validation_data` property; it now receives a `Context` and reads the row being validated directly, which also removes the last reason the rules needed the service at all. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> (cherry picked from commit 3a8dd87)
…the auth forms `Nails\Auth\Validator\User\Identity` owns the email/username rules (required, format, length, uniqueness, per `APP_NATIVE_LOGIN_USING`) and the "already registered" message; `Identifier` owns the login identifier rule. Registration, social sign-on data capture, admin account creation, login and forgotten-password previously each rebuilt these rules with small differences; they now extend the shared validators via `addRules()`/`setRules()`. Both classes are unit tested with the uniqueness rule stubbed, so no database is needed. Behaviour notes: registration and social sign-on now also enforce `alpha_dash_period` and `max_length[150]` on usernames (previously admin-only); admin account creation's "already registered" message now carries the forgotten-password link and uses the `auth_register_*_is_unique` lines rather than `fv_*_already_registered`. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> (cherry picked from commit 7a47ee8)
The merge rule compared against `$oInput->post('user_id')`; it now reads the field from the data being validated via `Context::getValue()`.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
(cherry picked from commit 4b31413)
`tests/bootstrap.php` now calls `Nails\Testing::bootstrapModule()` (and `phpunit.xml` supplies the `PRIVATE_KEY` it needs), matching `nails/common` and the other modules, so tests can use the Factory, services and models without CodeIgniter. The `Validator\User` tests depend on this and failed on CI with "No containers registered for nails/common". Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> (cherry picked from commit be4baf0)
LArge refactor to improve the handling of importing suers. Anything but modest CSVs would cause timeouts with no sane path to recovery or reporting. This commit overhauls this feature to add that, and more. (cherry picked from commit df55b33)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cherry-picks the full module-auth batch from
feature/pre-new-admin, depends on nails/common#558.1c0aca2(5d25d8a) refactor: Migrate legacy form validation tobuildValidator()1b5c127(63bca4f) refactor: Load language lines via the Translation service48222e4(3a8dd87) refactor: Read cross-field values via the validationContextin import rulesfe2cb24(7a47ee8) feat: AddIdentityandIdentifiervalidators and use them across the auth forms28c5b58(4b31413) refactor: Read the target user viaContextin the merge validator9ad8cc9(be4baf0) chore: Boot Nails in the PHPUnit bootstrapb6b4fdb(df55b33) feat: Move user import processing to backgroundThe first 6 commits are the same validation-engine migration as the other modules in this cherry-pick series. The last one is a large, separate feature (54 files) moving CSV user-import processing to a background worker/cron job, added late to this batch — flagging for closer review than the rest.
Conflicts resolved
Most auto-merged cleanly despite touching
Login.php,PasswordForgotten.php,Register.php,MfaDevice.php,MfaQuestion.php,Accounts.php,Merge.php,Init.php— all independently changed ondevelop. Verified each merge result by checking imports resolve, referenced variables are declared, and (for theIdentity/Identifiervalidators) that the new classes are correctly imported and called.Three required manual fixes in
df55b33:developuses class-based permissions (userHasPermission(SomeClass::class)— a plain string throwsPermissionExceptioninnails/module-admin'sPermissionservice). Fixed in two places:Admin\Controller\Import::PERMISSIONandApi\Controller\Import::requirePermission(), both now returnPermission\Users\Create::class(matching the pattern already used elsewhere ondevelop, e.g.admin/views/Accounts/edit/inc-actions.php).developis already atMigration19; the incomingMigration18.php(creatinguser_import/user_import_itemtables) collided withdevelop's existingMigration18(which itself exists specifically to reconcile pre-new-admin→develop migration numbering). Restoreddevelop'sMigration18untouched and moved the new schema intoMigration20.php.composer.jsonconstraints. Addednails/module-api(used by the newApi\Controller\Import, not previously required),nails/module-cron(require) andnails/module-queue(require-dev + suggest) — all asdev-developto match this repo's existing constraint style, not the incomingdev-feature/pre-new-admin. Confirmed all three have the classes this feature needs already on their owndevelopbranches.Also dropped two now-unused imports (
use Nails\Auth\Model\User;fromdevelop's side,use Nails\Auth\Controller\BaseAdmin;from the incoming side) that neither survives the mergedAdmin\Controller\Import.Verification
(against
nails/common's branch and every other dependency'sdevelop— or, formodule-admin/module-cdn, their own open cherry-pick PRs — synced intovendor/)PRIVATE_KEY=abc123 ./vendor/bin/phpunit: 148/148 tests passing, 300 assertions.phpstan: 1 error, identical todevelopbaseline (pre-existing, unrelatedvariable.undefined) — no regressions.composer validate: composer.json is valid (lock-file staleness is expected/pre-existing in this local environment, not addressed here).Do not merge yet — holding for review, and this one especially given its size.
🤖 Generated with Claude Code