Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/components/password_confirmation_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
**field_options,
input_html: field_options[:input_html].to_h.merge(
id: input_id,
autocomplete: 'new-password',
class: ['password-confirmation__input', *field_options.dig(:input_html, :class)],
),
) %>
Expand All @@ -20,6 +21,7 @@
**field_options,
input_html: field_options[:input_html].to_h.merge(
id: input_confirmation_id,
autocomplete: 'new-password',
class: ['password-confirmation__input-confirmation', *field_options.dig(:input_html, :class)],
),
wrapper_html: field_options[:wrapper_html].to_h.merge(
Expand All @@ -28,7 +30,7 @@
error_messages: {
valueMissing: t('components.password_confirmation.errors.empty'),
},
) %>
) %>
<input
id="<%= toggle_id %>"
type="checkbox"
Expand Down
3 changes: 3 additions & 0 deletions app/components/password_confirmation_component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
lg-password-confirmation {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Default display of custom elements is inline, which can cause some unexpected layout if not otherwise accounted for. This was previously fine in the account creation flow because sibling elements were block elements so it appeared standalone, but usage in the preview page was broken without.

Before After
image image

display: block;
}
3 changes: 3 additions & 0 deletions app/views/devise/passwords/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
field_options: {
label: t('forms.passwords.edit.labels.password'),
required: true,
input_html: {
autocomplete: 'new-password',
},
},
) %>
<%= render 'devise/shared/password_strength', forbidden_passwords: @forbidden_passwords %>
Expand Down
7 changes: 6 additions & 1 deletion app/views/devise/sessions/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@
<%= render PasswordToggleComponent.new(
form: f,
class: 'margin-bottom-4',
field_options: { required: true },
field_options: {
required: true,
input_html: {
autocomplete: 'current-password',
},
},
) %>
<%= f.submit t('links.next'), full_width: true, wide: false %>
<% if @sign_in_a_b_test_bucket == :default %>
Expand Down
3 changes: 3 additions & 0 deletions app/views/event_disavowal/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
field_options: {
label: t('forms.passwords.edit.labels.password'),
required: true,
input_html: {
autocomplete: 'new-password',
},
},
) %>
<%= render 'devise/shared/password_strength', forbidden_passwords: @forbidden_passwords %>
Expand Down
3 changes: 3 additions & 0 deletions app/views/idv/review/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
field_options: {
label: t('idv.form.password'),
required: true,
input_html: {
autocomplete: 'current-password',
},
},
) %>
<div class="text-right margin-top-neg-4 margin-bottom-4">
Expand Down
10 changes: 9 additions & 1 deletion app/views/mfa_confirmation/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@
url: reauthn_user_password_path,
html: { autocomplete: 'off', method: 'post', class: 'margin-top-4' },
) do |f| %>
<%= render PasswordToggleComponent.new(form: f, field_options: { required: true }) %>
<%= render PasswordToggleComponent.new(
form: f,
field_options: {
required: true,
input_html: {
autocomplete: 'current-password',
},
},
) %>
<%= f.submit t('forms.buttons.continue'), class: 'display-block margin-y-5' %>
<% end %>
<%= render 'shared/cancel', link: account_path %>
3 changes: 3 additions & 0 deletions app/views/users/delete/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
name: :password,
label: t('idv.form.password'),
required: true,
input_html: {
autocomplete: 'current-password',
},
},
) %>

Expand Down
5 changes: 4 additions & 1 deletion app/views/users/passwords/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
name: :password,
label: t('forms.passwords.edit.labels.password'),
required: true,
input_html: { aria: { describedby: 'password-description' } },
input_html: {
aria: { describedby: 'password-description' },
autocomplete: 'new-password',
},
},
) %>
<%= render 'devise/shared/password_strength', forbidden_passwords: @forbidden_passwords %>
Expand Down
3 changes: 3 additions & 0 deletions app/views/users/verify_password/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
name: :password,
label: t('idv.form.password'),
required: true,
input_html: {
autocomplete: 'current-password',
},
},
) %>
<%= f.submit t('forms.buttons.continue'), class: 'margin-top-5' %>
Expand Down
15 changes: 15 additions & 0 deletions spec/components/password_confirmation_component_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'rails_helper'

RSpec.describe PasswordConfirmationComponent, type: :component do
let(:lookup_context) { ActionView::LookupContext.new(ActionController::Base.view_paths) }
let(:view_context) { ActionView::Base.new(lookup_context, {}, controller) }
let(:form) { SimpleForm::FormBuilder.new('', {}, view_context, {}) }

subject(:rendered) do
render_inline PasswordConfirmationComponent.new(form:)
end

it 'renders password fields with expected attributes' do
expect(rendered).to have_css('[type=password][autocomplete=new-password]', count: 2)
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class PasswordConfirmationComponentPreview < BaseComponentPreview
# @!group Preview
# @display form true
def default
render(PasswordConfirmationComponent.new(form: form_builder))
end
# @!endgroup

# @display form true
# @param toggle_label text
def workbench(toggle_label: nil)
render(
PasswordConfirmationComponent.new(
form: form_builder,
**{ toggle_label: }.compact,
),
)
end
end