Class: Shakha::SessionController

Inherits:
ApplicationController show all
Defined in:
app/controllers/shakha/session_controller.rb

Instance Method Summary collapse

Instance Method Details

#checkObject



16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/shakha/session_controller.rb', line 16

def check
  if signed_in?
    render json: { status: "active" }
  else
    render json: {
      status: "login_required",
      reason: "no_session"
    }, status: :unauthorized
  end
end

#destroyObject



27
28
29
30
31
# File 'app/controllers/shakha/session_controller.rb', line 27

def destroy
  current_session&.destroy
  cookies.delete(:shakha_session_token)
  render json: { status: "signed_out" }
end

#showObject



7
8
9
10
11
12
13
14
# File 'app/controllers/shakha/session_controller.rb', line 7

def show
  render json: {
    user_id: current_user&.pairwise_sub,
    email: current_user&.email,
    name: current_user&.name,
    expires_at: current_session&.expires_at&.iso8601
  }
end