Class: Shakha::SessionController

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

Instance Method Summary collapse

Instance Method Details

#checkObject



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

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

#showObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/shakha/session_controller.rb', line 5

def show
  unless signed_in?
    return render json: { error: "Authentication required" }, status: :unauthorized
  end

  render json: {
    user: {
      id: current_user.id,
      email: current_user.email,
      name: current_user.name,
      picture: current_user.picture,
      provider: current_user.provider
    },
    session: {
      expires_at: current_session.expires_at.iso8601
    }
  }
end