Skip to content

Stop generating button inside login helper method#112

Merged
RenzoMinelli merged 9 commits intomasterfrom
rm/remove-button-in-login-form-helper
Feb 10, 2026
Merged

Stop generating button inside login helper method#112
RenzoMinelli merged 9 commits intomasterfrom
rm/remove-button-in-login-form-helper

Conversation

@RenzoMinelli
Copy link
Copy Markdown
Contributor

Update login helper method to stop generating the button inside the form and require devs to do so

# Before:

<%= login_with_passkey_button("Log in", session_path: path) %>

# After:
<%= login_with_passkey_form_for(session_path: path) do |form| %>
  <%= form.submit "Log in" %>
<% end %>

This gives developers full control over button styling and form content.

@RenzoMinelli RenzoMinelli marked this pull request as ready for review January 29, 2026 18:22
Copy link
Copy Markdown
Collaborator

@santiagorodriguez96 santiagorodriguez96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! Thank you for adding those tests! ❤️

Comment thread CHANGELOG.md Outdated
Comment on lines +8 to +17
- BREAKING: `login_with_passkey_button` and `login_with_security_key_button` helpers have been renamed to `login_with_passkey_form_for` and `login_with_security_key_form_for`. They now take a block and no longer generate the submit button automatically. You need to explicitly add the button inside the block:
```erb
<%# Before %>
<%%= login_with_passkey_button("Log in with passkeys", session_path: user_session_path) %>

<%# After %>
<%%= login_with_passkey_form_for(session_path: user_session_path) do |form| %>
<%%= form.submit "Log in with passkeys" %>
<%% end %>
```
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it's worth noting that now users can add whatever they want inside the form (like a remember_me checkbox?

Comment thread lib/devise/webauthn/helpers/credentials_helper.rb Outdated
Comment thread spec/helpers/devise/webauthn/credentials_helper_spec.rb Outdated
Comment thread spec/helpers/devise/webauthn/credentials_helper_spec.rb Outdated
Comment thread spec/helpers/devise/webauthn/credentials_helper_spec.rb Outdated
Comment thread spec/helpers/devise/webauthn/credentials_helper_spec.rb Outdated
Comment thread spec/helpers/devise/webauthn/credentials_helper_spec.rb
Comment thread spec/helpers/devise/webauthn/credentials_helper_spec.rb
RenzoMinelli and others added 4 commits February 6, 2026 17:48
…button

BREAKING CHANGE: `login_with_passkey_button` and `login_with_security_key_button`
helpers have been renamed to `login_with_passkey_form_for` and
`login_with_security_key_form_for`. They now take a block and no longer
generate the submit button automatically.

Before:
  <%= login_with_passkey_button("Log in", session_path: path) %>

After:
  <%= login_with_passkey_form_for(session_path: path) do |form| %>
    <%= form.submit "Log in" %>
  <% end %>

This gives developers full control over button styling and form content.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@RenzoMinelli RenzoMinelli force-pushed the rm/remove-button-in-login-form-helper branch from d544026 to aa83641 Compare February 6, 2026 20:56
Comment thread .tool-versions Outdated
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add it to your locally ignore files 🙂

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in 6c0dd03

end

before do
Rails.application.try(:reload_routes_unless_loaded)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about only running this if in Rails 8 and Devise 4?

Suggested change
Rails.application.try(:reload_routes_unless_loaded)
require 'devise/version'
if Rails::VERSION::MAJOR >= 8 && Devise::VERSION < '5'
Rails.application.reload_routes_unless_loaded
end

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay updated in 6c0dd03

@RenzoMinelli RenzoMinelli merged commit 019ad35 into master Feb 10, 2026
25 checks passed
@RenzoMinelli RenzoMinelli deleted the rm/remove-button-in-login-form-helper branch February 10, 2026 16:32
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.

2 participants