-
Notifications
You must be signed in to change notification settings - Fork 9
Nested operation DecryptEmailToken
Vladislav Trotsenko edited this page Sep 27, 2019
·
8 revisions
The point of this nested operation is setting model from decrypted jwt email token payload.
module Api::V1::Users::Lib::Operation
class DecryptEmailToken < ApplicationOperation
step Macro::Contract::Schema(Api::V1::Users::Lib::Contract::DecryptEmailTokenValidation)
step Contract::Validate(), fail_fast: true
step Macro::Assign(to: :email_token, path: %w[contract.default email_token]) # sets to email_token to context
step :set_payload # extracts and sets payload from email_token to context
fail Macro::AddContractError(base: 'errors.verification.invalid_email_token'), fail_fast: true # add custom error
step :set_model # sets model by payload
fail Macro::Semantic(failure: :not_found), fail_fast: true # sets not_found status
end
end
RubyGarage is a leading software development and consulting company in Eastern Europe. Our main expertise includes Ruby and Ruby on Rails, but we successfully employ other technologies to deliver the best results to our clients. Check out our portfolio for even more exciting works!