mirror of
https://github.com/ENSL/ensl.org.git
synced 2025-02-05 07:51:18 +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.calibrate!(max_mem: 16 * 1024 * 1024)
|
||||||
# SCrypt::Engine.generate_salt
|
# SCrypt::Engine.generate_salt
|
||||||
SCRYPT_SALT_OPTS=
|
SCRYPT_SALT_OPTS=
|
||||||
|
SCRYPT_MAX_TIME=1
|
||||||
|
|
||||||
# Since this is inside Docker container, it doesn't really matter
|
# Since this is inside Docker container, it doesn't really matter
|
||||||
DEPLOY_PATH=/var/www
|
DEPLOY_PATH=/var/www
|
||||||
|
|
|
@ -1,14 +1,19 @@
|
||||||
|
|
||||||
|
ENV['SCRYPT_MAX_TIME'] ||= "0.03"
|
||||||
class UpdatePasswordsToScrypt < ActiveRecord::Migration[6.0]
|
class UpdatePasswordsToScrypt < ActiveRecord::Migration[6.0]
|
||||||
require 'scrypt'
|
require 'scrypt'
|
||||||
require 'user'
|
require 'user'
|
||||||
|
|
||||||
def up
|
def up
|
||||||
SCrypt::Engine.calibrate!(max_time: 0.03)
|
SCrypt::Engine.calibrate!(max_time: ENV['SCRYPT_MAX_TIME'])
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
User.all.order(:id).each do |user|
|
User.all.order(:id).each do |user|
|
||||||
|
user.team = nil unless user&.team&.present?
|
||||||
|
if user.valid?
|
||||||
user.update_password
|
user.update_password
|
||||||
user.save!
|
user.save!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in a new issue