Skip to content

Commit

Permalink
[Automated] Merged master into target k8s
Browse files Browse the repository at this point in the history
  • Loading branch information
va-vsp-bot authored Apr 9, 2024
2 parents 01861fe + b399e67 commit b5492e4
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,7 @@ rakelib/mockdata_synchronize.rake @department-of-veterans-affairs/octo-identity
rakelib/pension_burial.rake @department-of-veterans-affairs/mbs-core-team @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
rakelib/piilog_repl @department-of-veterans-affairs/backend-review-group @department-of-veterans-affairs/va-api-engineers
rakelib/prod @department-of-veterans-affairs/vfs-vaos @department-of-veterans-affairs/backend-review-group @department-of-veterans-affairs/va-api-engineers
rakelib/prod/user_credential.rake @department-of-veterans-affairs/octo-identity
rakelib/remove_va1995s_records.rake @department-of-veterans-affairs/govcio-vfep-codereviewers @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
rakelib/routes_csv.rake @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
rakelib/rswag.rake @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddServiceLevelsAndCredentialServiceProvidersToClientConfigs < ActiveRecord::Migration[7.1]
def change
add_column :client_configs, :service_levels, :string, array: true, default: %w[ial1 ial2 loa1 loa3 min]
add_column :client_configs, :credential_service_providers, :string, array: true, default: %w[logingov idme dslogon mhv]
end
end
4 changes: 3 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions rakelib/prod/user_credential.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# frozen_string_literal: true

desc 'Lock and unlock user credentials'
namespace :user_credential do
task :lock, %i[type credential_id requested_by] => :environment do |_, args|
namespace = 'UserCredential::Lock'
validate_args(args)
type = args[:type]
credential_id = args[:credential_id]
context = { type:, credential_id:, requested_by: args[:requested_by] }
log_task(namespace:, status: 'start', context:)
user_verification = UserVerification.where(["#{type}_uuid = ?", credential_id]).first
user_verification.lock!
log_task(namespace:, status: 'complete', context: context.merge(locked: user_verification.locked))
puts "#{namespace} complete - #{type}_uuid: #{credential_id}"
rescue => e
puts "#{namespace} failed - #{e.message}"
end

task :unlock, %i[type credential_id requested_by] => :environment do |_, args|
namespace = 'UserCredential::Unlock'
validate_args(args)
type = args[:type]
credential_id = args[:credential_id]
context = { type:, credential_id:, requested_by: args[:requested_by] }
log_task(namespace:, status: 'start', context:)
user_verification = UserVerification.where(["#{type}_uuid = ?", credential_id]).first
user_verification.unlock!
log_task(namespace:, status: 'complete', context: context.merge(locked: user_verification.locked))
puts "#{namespace} complete - #{type}_uuid: #{credential_id}"
rescue => e
puts "#{namespace} failed - #{e.message}"
end

def validate_args(args)
raise 'Missing required arguments' if args[:type].blank? ||
args[:credential_id].blank? ||
args[:requested_by].blank?
end

def log_task(namespace:, status:, context:)
Rails.logger.info("[#{namespace}] rake task #{status}", context)
end
end

0 comments on commit b5492e4

Please sign in to comment.