fix: use consistent underscored subject name for form param keys#728
Merged
fix: use consistent underscored subject name for form param keys#728
Conversation
Remove `slugify()` from the `as:` option and `get_params/2` in all form components. The `as:` option determines the key under which form params are nested, and `get_params/2` extracts them back out. These must match each other AND the ash_authentication plugs, which use `to_string()` without slugification. Previously some components slugified (producing `"admin-user"`) while others didn't (producing `"admin_user"`), and the plugs always expected the underscored form. This caused silent param lookup failures for multi-word subject names like `AdminUser`. Closes #726
|
Just tested this on my repo and it works like a charm, no issues :) |
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
slugify()from theas:option andget_params/2across all form components so that form param keys consistently use the underscored subject name (e.g."admin_user"not"admin-user")Password.Plug.subject_params/2,MagicLink.Plug.subject_params/2) expect when extracting params viato_string()without slugificationAdminUserAffected components
as:option fixed (was slugifying, now usesto_string()only):Password.SignInFormTotp.Verify2faFormTotp.SetupFormTotp.SignInFormRecoveryCode.VerifyFormget_params/2fixed (was slugifying the lookup key):Password.SignInFormPassword.RegisterFormPassword.ResetFormTotp.SetupFormTotp.SignInFormTotp.Verify2faFormRecoveryCode.VerifyFormConfirm.FormMagicLinkReset.FormNote:
slugify()is intentionally retained onid:values (HTML element IDs) where hyphens are conventional.Supersedes #727 with a more complete fix.
Closes #726
Test plan
mix compilepassesmix test— 131 tests, 0 failuresAdminUser) to verify sign-in, registration, password reset, and magic link forms all work end-to-end