Class: SessionChecksController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/session_checks_controller.rb

Instance Method Summary collapse

Instance Method Details

#dont_update_request_timeObject

This ensures this request ping doesn’t update their last access time.



20
21
22
# File 'app/controllers/session_checks_controller.rb', line 20

def dont_update_request_time
  request.env['devise.skip_trackable'] = true
end

#time_to_session_expiryObject

Find it there is a session, and if it has any warden information. If so, the user is logged in.



8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/session_checks_controller.rb', line 8

def time_to_session_expiry
  session_exists = false
  session_expires_in = 0
  if current_user
    session_exists = true
    # This calculates how many seconds there are until they are logged out
    session_expires_in = User.timeout_in - Time.now.utc.to_i + session['warden.user.user.session']['last_request_at'].to_i rescue 1000000
  end
  render json: {session_exists: session_exists, session_expires_in: session_expires_in}
end