Module: JwtAuthEngine::ResponseRenderable

Included in:
ApplicationController
Defined in:
app/controllers/concerns/jwt_auth_engine/response_renderable.rb

Overview

Concern with shared JSON response helpers for engine controllers.

Instance Method Summary collapse

Instance Method Details

#render_internal_server_error(errors:) ⇒ Object



19
20
21
# File 'app/controllers/concerns/jwt_auth_engine/response_renderable.rb', line 19

def render_internal_server_error(errors:)
  render_error(errors: errors, status: :internal_server_error)
end

#render_success(**data) ⇒ Object



6
7
8
9
# File 'app/controllers/concerns/jwt_auth_engine/response_renderable.rb', line 6

def render_success(**data)
  render json: { success: true, data: data.except(:status) },
         status: data[:status] || :ok
end

#render_unauthorized(message = 'Unauthorized') ⇒ Object



11
12
13
# File 'app/controllers/concerns/jwt_auth_engine/response_renderable.rb', line 11

def render_unauthorized(message = 'Unauthorized')
  render_error(errors: message, status: :unauthorized)
end

#render_validation_error(errors:) ⇒ Object



15
16
17
# File 'app/controllers/concerns/jwt_auth_engine/response_renderable.rb', line 15

def render_validation_error(errors:)
  render_error(errors: errors, status: :unprocessable_entity)
end