Module: CommandTower::Workflows::Auth::IdentityErrorStatus

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

Overview

HTTP status mapping for the identity lifecycle cluster: email verification, password recovery sessions, and password reset. Session authentication statuses live in SessionErrorStatus; signup statuses in SignupErrorStatus.

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
28
29
30
31
32
# File 'app/workflows/command_tower/workflows/auth/identity_error_status.rb', line 12

def http_status_for(error)
  case error
  when CommandTower::Errors::Auth::PasswordRecoverySessionMissingError,
       CommandTower::Errors::Auth::PasswordRecoverySessionInvalidError,
       CommandTower::Errors::Auth::PasswordRecoverySessionExpiredError,
       CommandTower::Errors::Auth::PasswordResetInvalidTokenError
    :unauthorized
  when CommandTower::Errors::Auth::PasswordRecoverySessionRateLimitError,
       CommandTower::Errors::Auth::PasswordRecoveryIpRateLimitError
    :too_many_requests
  when CommandTower::Errors::Auth::VerificationCodeInvalidError,
       CommandTower::Errors::ValidationError
    :unprocessable_entity
  when CommandTower::Errors::Auth::PasswordResetUnavailableError
    :service_unavailable
  when CommandTower::Errors::Auth::VerificationSendFailedError
    :bad_gateway
  else
    :internal_server_error
  end
end