Module: CommandTower::Workflows::Auth::SessionErrorStatus

Defined in:
app/workflows/command_tower/workflows/auth/session_error_status.rb

Overview

HTTP status mapping for session authentication and authorization failures only. Scoped deliberately narrow, same rationale as SignupErrorStatus: a platform-wide table would let unrelated products inherit these choices.

Class Method Summary collapse

Class Method Details

.http_status_for(error) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/workflows/command_tower/workflows/auth/session_error_status.rb', line 12

def http_status_for(error)
  case error
  when CommandTower::Errors::Auth::EmailVerificationRequiredError
    :precondition_failed
  when CommandTower::Errors::Auth::CsrfMissingError,
       CommandTower::Errors::Auth::CsrfMismatchError,
       CommandTower::Errors::ForbiddenError
    :forbidden
  when CommandTower::Errors::Auth::InvalidCredentialsError,
       CommandTower::Errors::Auth::ImpersonationSessionExpiredError,
       CommandTower::Errors::UnauthorizedError
    :unauthorized
  else
    :internal_server_error
  end
end