Class: CommandTower::Secrets::Verify
- Inherits:
-
Object
- Object
- CommandTower::Secrets::Verify
- Defined in:
- app/services/command_tower/secrets/verify.rb
Overview
Redeems a previously issued user secret. Called from capability services, so it stays a plain domain object with a narrow outcome.
Defined Under Namespace
Classes: Redemption
Constant Summary collapse
- NOT_FOUND_MSG =
"Secret not found"
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(secret:, reason:, access_count: false) ⇒ Verify
constructor
A new instance of Verify.
Constructor Details
#initialize(secret:, reason:, access_count: false) ⇒ Verify
Returns a new instance of Verify.
36 37 38 39 40 |
# File 'app/services/command_tower/secrets/verify.rb', line 36 def initialize(secret:, reason:, access_count: false) @secret = secret @reason = reason @access_count = access_count end |
Class Method Details
.call(secret:, reason:, access_count: false) ⇒ Object
32 33 34 |
# File 'app/services/command_tower/secrets/verify.rb', line 32 def self.call(secret:, reason:, access_count: false) new(secret:, reason:, access_count:).call end |
Instance Method Details
#call ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/services/command_tower/secrets/verify.rb', line 42 def call record = UserSecret.find_record(secret:, reason:, access_count:) return Redemption.failure(record:, msg: NOT_FOUND_MSG) if record[:found] == false if record[:valid] == false reason_text = record[:record].invalid_reason.join(" ") record[:record].destroy if CommandTower.config.delete_secret_after_invalid return Redemption.failure(record:, msg: "Secret is invalid. #{reason_text}") end Redemption.success(user: record[:user], record:) end |