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

Update default password_length to be 8 minimum #5675

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ module Test

# Range validation for password length
mattr_accessor :password_length
@@password_length = 6..128
@@password_length = 8..128

# The time the user will be remembered without asking for credentials again.
mattr_accessor :remember_for
Expand Down
2 changes: 1 addition & 1 deletion lib/devise/models/validatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module Models
# Validatable adds the following options to +devise+:
#
# * +email_regexp+: the regular expression used to validate e-mails;
# * +password_length+: a range expressing password length. Defaults to 6..128.
# * +password_length+: a range expressing password length. Defaults to 8..128.
#
module Validatable
# All validations used by this module.
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/templates/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@

# ==> Configuration for :validatable
# Range for password length.
config.password_length = 6..128
config.password_length = 8..128

# Email regex used to validate email formats. It simply asserts that
# one (and only one) @ exists in the given string. This is mainly
Expand Down
6 changes: 3 additions & 3 deletions test/models/validatable_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ class ValidatableTest < ActiveSupport::TestCase
assert user.errors.added?(:password_confirmation, :confirmation, attribute: "Password")
end

test 'should require a password with minimum of 7 characters' do
user = new_user(password: '12345', password_confirmation: '12345')
test 'should require a password with minimum of 8 characters' do
user = new_user(password: '1234567', password_confirmation: '1234567')
assert user.invalid?
assert_equal 'is too short (minimum is 7 characters)', user.errors[:password].join
assert_equal 'is too short (minimum is 8 characters)', user.errors[:password].join
end

test 'should require a password with maximum of 72 characters long' do
Expand Down
2 changes: 1 addition & 1 deletion test/rails_app/lib/shared_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module SharedUser
included do
devise :database_authenticatable, :confirmable, :lockable, :recoverable,
:registerable, :rememberable, :timeoutable,
:trackable, :validatable, :omniauthable, password_length: 7..72,
:trackable, :validatable, :omniauthable, password_length: 8..72,
reconfirmable: false

attr_accessor :other_key
Expand Down