Class: CommandTower::Secrets::Verify

Inherits:
CommandTower::ServiceBase show all
Defined in:
app/services/command_tower/secrets/verify.rb

Constant Summary

Constants inherited from CommandTower::ServiceBase

CommandTower::ServiceBase::ON_ARGUMENT_VALIDATION

Instance Method Summary collapse

Methods inherited from CommandTower::ServiceBase

inherited, #internal_validate, #service_base_logging, #validate!

Methods included from ArgumentValidation

included

Methods included from CommandTower::ServiceLogging

#aletered_message, #class_name, #log, #log_error, #log_info, #log_prefix, #log_warn, #logger, #service_id

Instance Method Details

#callObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/services/command_tower/secrets/verify.rb', line 9

def call
  record = UserSecret.find_record(secret:, reason:, access_count:)

  if record[:found] == false
    context.fail!(record:, msg: "Secret not found")
  end

  if record[:valid] == false
    if CommandTower.config.delete_secret_after_invalid
      record[:record].destroy
    end

    context.fail!(record:, msg: "Secret is invalid. #{record[:record].invalid_reason.join(" ")}")
  end

  context.user = record[:user]
end