Fix: scope login_with_passkey_form_for to the Devise resource#134
Merged
RenzoMinelli merged 5 commits intomasterfrom Apr 6, 2026
Merged
Fix: scope login_with_passkey_form_for to the Devise resource#134RenzoMinelli merged 5 commits intomasterfrom
RenzoMinelli merged 5 commits intomasterfrom
Conversation
The form helpers (login_with_passkey_form_for, etc.) used form_with without a scope, so form builder fields like f.check_box :remember_me generated name="remember_me" instead of name="account[remember_me]". Since the passkey strategy reads params[scope][:remember_me], the value was never found. Resolve the scope via Devise::Mapping.find_scope! and pass it to form_with. Switch the internal public_key_credential hidden field to hidden_field_tag so it stays at the top-level params where strategies and controllers expect it. Update controllers to read :name from the now-scoped params. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Creation form helpers shouldn't scope fields under the Devise resource since those fields (like :name) are passkey/security key attributes, not account attributes. Only login_with_passkey_form_for needs the scope so that f.check_box :remember_me generates account[remember_me]. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
santiagorodriguez96
approved these changes
Apr 6, 2026
| end | ||
|
|
||
| def login_with_passkey_form_for(resource_or_resource_name, **options, &block) | ||
| scope = Devise::Mapping.find_scope!(resource_or_resource_name) |
Collaborator
There was a problem hiding this comment.
So convenient 😍
| ### Fixed | ||
|
|
||
| - Fix form helpers (`passkey_creation_form_for`, `login_with_passkey_button`, `security_key_creation_form_for`, `login_with_security_key_button`) to accept a `resource_name` instead of requiring the `resource` object from the view context. [#114](https://github.com/cedarcode/devise-webauthn/pull/114) [@RenzoMinelli] | ||
| - Scope `login_with_passkey_form_for` to the Devise resource so that form builder fields (e.g. `f.check_box :remember_me`) are properly namespaced (e.g. `account[remember_me]`). [#134](https://github.com/cedarcode/devise-webauthn/pull/134) [@RenzoMinelli] |
Collaborator
There was a problem hiding this comment.
nit: this looks more like a feature/enhancement than a fix 🤔
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
login_with_passkey_form_fornow passesscope:toform_with, resolved viaDevise::Mapping.find_scope!. This makes form builder fields likef.check_box :remember_mecorrectly generatename="account[remember_me]"instead of the unscopedname="remember_me".public_key_credentialhidden field in that helper is switched tohidden_field_tagso it stays at the top-level params where strategies expect it.Follows up on #133 where
check_box_tag "account[remember_me]"was used as a workaround because the form builder wasn't scoping fields to the resource.Test plan
f.check_box :remember_meworks end-to-end🤖 Generated with Claude Code