mirror of
https://github.com/ENSL/ensl.org.git
synced 2025-02-04 23:41:12 +00:00
Update scrypt migration
This commit is contained in:
parent
af5b4140dd
commit
7ae3487d59
2 changed files with 9 additions and 3 deletions
|
@ -12,6 +12,7 @@ APP_SECRET=randomstringhere
|
|||
# SCrypt::Engine.calibrate!(max_mem: 16 * 1024 * 1024)
|
||||
# SCrypt::Engine.generate_salt
|
||||
SCRYPT_SALT_OPTS=
|
||||
SCRYPT_MAX_TIME=1
|
||||
|
||||
# Since this is inside Docker container, it doesn't really matter
|
||||
DEPLOY_PATH=/var/www
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
|
||||
ENV['SCRYPT_MAX_TIME'] ||= "0.03"
|
||||
class UpdatePasswordsToScrypt < ActiveRecord::Migration[6.0]
|
||||
require 'scrypt'
|
||||
require 'user'
|
||||
|
||||
def up
|
||||
SCrypt::Engine.calibrate!(max_time: 0.03)
|
||||
SCrypt::Engine.calibrate!(max_time: ENV['SCRYPT_MAX_TIME'])
|
||||
ActiveRecord::Base.transaction do
|
||||
User.all.order(:id).each do |user|
|
||||
user.update_password
|
||||
user.save!
|
||||
user.team = nil unless user&.team&.present?
|
||||
if user.valid?
|
||||
user.update_password
|
||||
user.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue