Skip to content

fix: use consistent underscored subject name for form param keys#728

Merged
jimsynz merged 1 commit intomainfrom
fix/consistent-form-param-keys
Apr 14, 2026
Merged

fix: use consistent underscored subject name for form param keys#728
jimsynz merged 1 commit intomainfrom
fix/consistent-form-param-keys

Conversation

@jimsynz
Copy link
Copy Markdown
Collaborator

@jimsynz jimsynz commented Apr 14, 2026

Summary

  • Remove slugify() from the as: option and get_params/2 across all form components so that form param keys consistently use the underscored subject name (e.g. "admin_user" not "admin-user")
  • This matches what the ash_authentication plugs (Password.Plug.subject_params/2, MagicLink.Plug.subject_params/2) expect when extracting params via to_string() without slugification
  • Previously, some components slugified while others didn't, causing silent param lookup failures for multi-word subject names like AdminUser

Affected components

as: option fixed (was slugifying, now uses to_string() only):

  • Password.SignInForm
  • Totp.Verify2faForm
  • Totp.SetupForm
  • Totp.SignInForm
  • RecoveryCode.VerifyForm

get_params/2 fixed (was slugifying the lookup key):

  • Password.SignInForm
  • Password.RegisterForm
  • Password.ResetForm
  • Totp.SetupForm
  • Totp.SignInForm
  • Totp.Verify2faForm
  • RecoveryCode.VerifyForm
  • Confirm.Form
  • MagicLink
  • Reset.Form

Note: slugify() is intentionally retained on id: values (HTML element IDs) where hyphens are conventional.

Supersedes #727 with a more complete fix.

Closes #726

Test plan

  • mix compile passes
  • mix test — 131 tests, 0 failures
  • Manual test with a multi-word subject name (e.g. AdminUser) to verify sign-in, registration, password reset, and magic link forms all work end-to-end

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
@brandonpollack23
Copy link
Copy Markdown

Just tested this on my repo and it works like a charm, no issues :)

@jimsynz jimsynz merged commit 6a10e69 into main Apr 14, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

inconsistent slugging on forms

2 participants