Class: StandardId::Web::SessionsController

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

Constant Summary

Constants included from RateLimitHandling

RateLimitHandling::RATE_LIMIT_STORE

Instance Method Summary collapse

Methods included from StandardId::WebAuthentication

#current_account, #current_scope_names, #current_session, #revoke_current_session!

Methods included from ControllerPolicy

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

Instance Method Details

#destroyObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/standard_id/web/sessions_controller.rb', line 12

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

  if session == current_session
    # If revoking current session, sign out and redirect
    revoke_current_session!
    redirect_to "/", notice: "Session revoked. You have been signed out."
  else
    # Revoke other session
    session.revoke!
    redirect_to sessions_path, notice: "Session revoked successfully"
  end
rescue ActiveRecord::RecordNotFound
  redirect_to sessions_path, alert: "Session not found"
end

#indexObject



7
8
9
10
# File 'app/controllers/standard_id/web/sessions_controller.rb', line 7

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