mirror of
https://github.com/opf/openproject.git
synced 2026-06-13 19:20:00 +00:00
Update to use constant instead of magic numbers
This commit is contained in:
@@ -35,6 +35,8 @@ class Setting < ApplicationRecord
|
||||
extend Aliases
|
||||
extend MailSettings
|
||||
|
||||
PASSWORD_MAX_LENGTH = 128
|
||||
|
||||
ENCODINGS = %w(US-ASCII
|
||||
windows-1250
|
||||
windows-1251
|
||||
@@ -95,7 +97,7 @@ class Setting < ApplicationRecord
|
||||
numericality: {
|
||||
only_integer: true,
|
||||
greater_than_or_equal_to: 1,
|
||||
less_than_or_equal_to: 128,
|
||||
less_than_or_equal_to: PASSWORD_MAX_LENGTH,
|
||||
if: ->(setting) { setting.name == "password_min_length" }
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ See COPYRIGHT and LICENSE files for more details.
|
||||
type: :number,
|
||||
size: 6,
|
||||
min: 1,
|
||||
max: 128,
|
||||
max: Setting::PASSWORD_MAX_LENGTH,
|
||||
input_width: :small
|
||||
|
||||
form.check_box_group(name: :password_active_rules,
|
||||
|
||||
@@ -829,7 +829,7 @@ module Settings
|
||||
password_min_length: {
|
||||
default: 10,
|
||||
format: :integer,
|
||||
allowed: (1..128)
|
||||
allowed: -> { 1..Setting::PASSWORD_MAX_LENGTH }
|
||||
},
|
||||
# TODO: turn into array of ints
|
||||
# Requires a migration to be written
|
||||
|
||||
Reference in New Issue
Block a user