generates RSA key pairs for migrated accounts

This commit is contained in:
robcolbert 2019-07-04 16:25:06 -04:00
parent a0a1c8d1f9
commit 864195980e
1 changed files with 17 additions and 0 deletions

View File

@ -0,0 +1,17 @@
# frozen_string_literal: true
task fix_key_pairs: 'gabsocial:fix_key_pairs'
namespace :gabsocial do
desc 'Generates key pairs for migrated accounts'
task :fix_key_pairs => :environment do
Account.select(:id, :username, :private_key, :public_key).all.each do |a|
if a.public_key == "tobefilled"
keypair = OpenSSL::PKey::RSA.new(2048)
private_key = keypair.to_pem
public_key = keypair.public_key.to_pem
a.update_columns private_key: private_key, public_key: public_key
end
end
end
end