Class: CommandTower::Workflows::Admin::Users::UpdateEmailWorkflow
- Inherits:
-
CommandTower::Workflows::ApplicationWorkflow
- Object
- CommandTower::Workflows::ApplicationWorkflow
- CommandTower::Workflows::Admin::Users::UpdateEmailWorkflow
- Defined in:
- app/workflows/command_tower/workflows/admin/users/update_email_workflow.rb
Constant Summary
Constants inherited from CommandTower::Workflows::ApplicationWorkflow
CommandTower::Workflows::ApplicationWorkflow::ALLOWED_RETRY_STRATEGIES, CommandTower::Workflows::ApplicationWorkflow::InvalidTransactionResult, CommandTower::Workflows::ApplicationWorkflow::TransactionFailure
Instance Method Summary collapse
Methods inherited from CommandTower::Workflows::ApplicationWorkflow
call, call_from_job, continuation_max_attempts, declared_retry_strategy, mark_impersonation_activity!, retry_strategy, validate_retry_strategy!
Methods included from Impersonation::ActivityDeclaration
Methods included from Logging::LifecycleDeclaration
Methods included from Execution::ContextAccess
#audit, #execution_context, #log_debug, #log_error, #log_info, #log_warn, #publish_event
Methods included from Transactional
#fail_transaction!, #transaction
Instance Method Details
#call(id:, user:, email:, scope_value: nil) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/workflows/command_tower/workflows/admin/users/update_email_workflow.rb', line 10 def call(id:, user:, email:, scope_value: nil) resolved = IdentityMutation.resolve_target(id:, principal: user, scope_value:) return resolved if resolved.is_a?(CommandTower::Workflows::WorkflowResult) target = resolved.user transaction do result = CommandTower::Services::Admin::Users::UpdateEmail.call( user: target, email: ) fail_transaction!(IdentityMutation.map_service_failure(result)) unless result.success? updated = result.data[:user] if result.data[:changed] audit( :admin_user_email_changed, subject: updated, affected_user: updated, changes: {}, metadata: { email_changed: true }, attribution_mode: :admin_direct ) end success( payload: CommandTower::Serializers::Admin::Users::UserSerializer.serialize(updated), http_status: :ok ) end end |