mirror of
https://github.com/diaspora/diaspora.git
synced 2026-01-10 07:38:10 -05:00
Merge branch 'develop' into api
This commit is contained in:
13
db/migrate/20171229175654_add_devise_two_factor_to_users.rb
Normal file
13
db/migrate/20171229175654_add_devise_two_factor_to_users.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AddDeviseTwoFactorToUsers < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
change_table :users, bulk: true do |t|
|
||||
t.string :encrypted_otp_secret
|
||||
t.string :encrypted_otp_secret_iv
|
||||
t.string :encrypted_otp_secret_salt
|
||||
t.integer :consumed_timestep
|
||||
t.boolean :otp_required_for_login
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AddTwoFactorBackupableToUser < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
add_column :users, :otp_backup_codes, :text
|
||||
end
|
||||
end
|
||||
11
db/migrate/20190509125709_fix_missing_remote_photo_fields.rb
Normal file
11
db/migrate/20190509125709_fix_missing_remote_photo_fields.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class FixMissingRemotePhotoFields < ActiveRecord::Migration[5.1]
|
||||
def up
|
||||
Photo.where(remote_photo_path: nil).each do |photo|
|
||||
photo.write_attribute(:unprocessed_image, photo.read_attribute(:processed_image))
|
||||
photo.update_remote_path
|
||||
photo.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
52
db/migrate/20190511150503_decrypt_two_factor_secret.rb
Normal file
52
db/migrate/20190511150503_decrypt_two_factor_secret.rb
Normal file
@@ -0,0 +1,52 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class DecryptTwoFactorSecret < ActiveRecord::Migration[5.1]
|
||||
class User < ApplicationRecord
|
||||
end
|
||||
|
||||
def up
|
||||
add_column :users, :plain_otp_secret, :string
|
||||
|
||||
key = twofa_encryption_key
|
||||
decrypt_existing_secrets(key) if key
|
||||
|
||||
change_table :users, bulk: true do |t|
|
||||
t.remove :encrypted_otp_secret
|
||||
t.remove :encrypted_otp_secret_iv
|
||||
t.remove :encrypted_otp_secret_salt
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def twofa_encryption_key
|
||||
if AppConfig.heroku?
|
||||
ENV["TWOFA_ENCRYPTION_KEY"]
|
||||
else
|
||||
key_file = File.expand_path("../../config/initializers/twofa_encryption_key.rb", File.dirname(__FILE__))
|
||||
|
||||
if File.exist? key_file
|
||||
require key_file
|
||||
File.delete(key_file)
|
||||
|
||||
return Diaspora::Application.config.twofa_encryption_key
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def decrypt_existing_secrets(key)
|
||||
User.where.not(encrypted_otp_secret: nil).each do |user|
|
||||
user.plain_otp_secret = Encryptor.decrypt(
|
||||
value: user.encrypted_otp_secret.unpack("m").first,
|
||||
key: key,
|
||||
iv: user.encrypted_otp_secret_iv.unpack("m").first,
|
||||
salt: user.encrypted_otp_secret_salt.slice(1..-1).unpack("m").first
|
||||
)
|
||||
user.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
14
db/migrate/20190701234716_photos_remove_comment_count.rb
Normal file
14
db/migrate/20190701234716_photos_remove_comment_count.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class PhotosRemoveCommentCount < ActiveRecord::Migration[5.1]
|
||||
class Comment < ApplicationRecord
|
||||
end
|
||||
|
||||
def change
|
||||
remove_column :photos, :comments_count, :integer
|
||||
|
||||
reversible do |change|
|
||||
change.up { Comment.where(commentable_type: "Photo").delete_all }
|
||||
end
|
||||
end
|
||||
end
|
||||
9
db/migrate/20190703231700_fix_pending_profile_photos.rb
Normal file
9
db/migrate/20190703231700_fix_pending_profile_photos.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class FixPendingProfilePhotos < ActiveRecord::Migration[5.1]
|
||||
def up
|
||||
Photo.where(pending: true).each do |photo|
|
||||
photo.update(pending: false) if Profile.where(image_url: photo.url(:thumb_large)).exists?
|
||||
end
|
||||
end
|
||||
end
|
||||
10
db/migrate/20191018014242_remove_chat.rb
Normal file
10
db/migrate/20191018014242_remove_chat.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class RemoveChat < ActiveRecord::Migration[5.1]
|
||||
def up
|
||||
remove_column :aspects, :chat_enabled
|
||||
drop_table :chat_contacts
|
||||
drop_table :chat_fragments
|
||||
drop_table :chat_offline_messages
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user