20220330092945_object_manager_update_user_password.rb 721 B

12345678910111213141516171819
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class ObjectManagerUpdateUserPassword < ActiveRecord::Migration[6.1]
  3. def up
  4. # return if it's a new setup
  5. return if !Setting.exists?(name: 'system_init_done')
  6. UserInfo.current_user_id = 1
  7. object_type = ObjectLookup.find_by(name: 'User')
  8. attr = ObjectManager::Attribute.find_by object_lookup_id: object_type.id, name: 'password'
  9. # password length is capped at 1000 in PasswordPolicy::MaxLength::MAX_LENGTH
  10. # if user copy-pastes a very long string
  11. # this ensures that max length check is triggered preventing saving of truncated password
  12. attr.data_option[:maxlength] = 1001
  13. attr.save!
  14. end
  15. end