Class: CommandTower::Workflows::Auth::Session::ShowWorkflow

Inherits:
CommandTower::Workflows::ApplicationWorkflow show all
Defined in:
app/workflows/command_tower/workflows/auth/session/show_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

included

Methods included from Logging::LifecycleDeclaration

included

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(current_user:, auth_context:) ⇒ 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
# File 'app/workflows/command_tower/workflows/auth/session/show_workflow.rb', line 10

def call(current_user:, auth_context:)
  response_effects = {
    set_expire_header: auth_context.token_expires_at
  }

  if auth_context.generated_token.present?
    response_effects[:set_token] = {
      token: auth_context.generated_token,
      expires_at: auth_context.token_expires_at
    }
    response_effects[:ensure_csrf_cookie] = { rotate: csrf_rotate_on_reset? }
  end

  impersonation_session = impersonation_session_for(auth_context)

  success(
    payload: CommandTower::Serializers::Auth::SessionResponseSerializer.serialize(
      user: current_user,
      token_expires_at: auth_context.token_expires_at,
      impersonation_session:,
      actor: auth_context.actor_user
    ),
    http_status: :ok,
    response_effects: response_effects
  )
end