chore(encryption): task rotating api particulier token encrypted attributes

This commit is contained in:
Colin Darie 2024-08-22 17:33:45 +02:00
parent 3ac671576b
commit ca7100c7af
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4
2 changed files with 72 additions and 0 deletions

View file

@ -0,0 +1,22 @@
# frozen_string_literal: true
module Maintenance
class RotateAPIParticulierTokenEncryptionTask < MaintenanceTasks::Task
def collection
# rubocop:disable DS/Unscoped
Procedure.unscoped.where.not(encrypted_api_particulier_token: nil)
# rubocop:enable DS/Unscoped
end
def process(procedure)
decrypted_token = procedure.api_particulier_token
procedure.api_particulier_token = decrypted_token
procedure.save!(validate: false)
end
def count
collection.count
end
end
end