Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 7.1 updated password validation changed rendering of password inputs #1825

Open
arg opened this issue Nov 22, 2023 · 0 comments
Open

Comments

@arg
Copy link

arg commented Nov 22, 2023

I'm not entirely sure who I should report this issue to, but it looks like has_secure_password change made in rails/rails#47708 partially broke rendering of password inputs, as it doesn't use the regular validates_length_of anymore, but instead goes with a custom validation. So the following snippet renders different output in Rails 7.0 and Rails 7.1

class User < ApplicationRecord
  # has email attribute
  has_secure_password
end
...
@user = User.new
...
= simple_form_for @user, url: login_path, method: :post do |f|
  = f.input :email
  = f.input :password

Environment

  • Ruby 3.2.0
  • Rails 7.1.2
  • Simple Form 5.3.0

Current behavior

<form class="simple_form form-vertical new_user" id="new_user" novalidate="novalidate" action="/login" accept-charset="UTF-8" method="post">
  <div class="field">
    <label for="user_email">Email</label>
    <input maxlength="100" type="email" size="100" name="user[email]" id="user_email">
  </div>
  <div class="field">
    <label for="user_password">Password</label>
    <input type="password" name="user[password]" id="user_password">
  </div>
</form>

Expected behavior

Notice the maxlength="72" and size="72" attributes of password input

<form class="simple_form form-vertical new_user" id="new_user" novalidate="novalidate" action="/login" accept-charset="UTF-8" method="post">
  <div class="field">
    <label for="user_email">Email</label>
    <input maxlength="100" type="email" size="100" name="user[email]" id="user_email">
  </div>
  <div class="field">
    <label for="user_password">Password</label>
    <input maxlength="72" size="72" type="password" name="user[password]" id="user_password">
  </div>
</form>

Of course, as a workaround we can just specify maxlength for every password, password confirmation and password challenge input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant