Sha256: 4a02a5484a997140012b18c000cc99b523c101b33374d009252469eb57217b06
Contents?: true
Size: 1.39 KB
Versions: 146
Compression:
Stored size: 1.39 KB
Contents
// Create a timer that will poll to see if the user's session is still valid. // If it isn't, the server returns a 401 unauthorised causing a redirect the login page. // Note that we could in the future display a message letting them know their session // will expired in X seconds. The controller action we hit here could be expanded to // to render some js that would insert than into the page. // Note we don't want to poll if we are sat on the login page anyway. For one thing on Heroku it // would prevent a dyno sleeping, but its also a waste of resources. // $(document).ready(function() { var login_path ="<%= Renalware::Engine.routes.url_helpers.new_user_session_path %>"; var defaultPollFreq = <%= Renalware.config.session_timeout_polling_frequency.to_i %>; var frequency_s = defaultPollFreq; // This is a global window function so that we can call it directly from capybara tests to // bypass having to wait for the session polling interval to tick over. window.sessionTimeoutCheck = function(){ if(window.location.pathname != login_path) { $.getScript("<%= Renalware::Engine.routes.url_helpers.session_timed_out_path %>") .fail(function(jqxhr, settings, exception) { <% unless Rails.env.test? %> console.log("Failed to query for session timeout"); <% end %> }); } }; setInterval(window.sessionTimeoutCheck, (frequency_s * 1000)); });
Version data entries
146 entries across 146 versions & 1 rubygems