Class: StandardId::Api::SessionsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/standard_id/api/sessions_controller.rb

Constant Summary

Constants included from RateLimitHandling

RateLimitHandling::RATE_LIMIT_STORE

Instance Method Summary collapse

Methods included from ControllerPolicy

all_controllers, authenticated_controllers, public_controllers, register, registry_snapshot, reset_registry!

Instance Method Details

#destroyObject



15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/standard_id/api/sessions_controller.rb', line 15

def destroy
  session = .sessions.find_by(id: params[:id])

  unless session
    render json: { error: "not_found", error_description: "Session not found" }, status: :not_found
    return
  end

  session.revoke!(reason: "api_revocation")
  head :no_content
end

#indexObject



9
10
11
12
13
# File 'app/controllers/standard_id/api/sessions_controller.rb', line 9

def index
  sessions = .sessions.active.order(created_at: :desc)

  render json: sessions.map { |session| serialize_session(session) }
end