Sha256: 55268d17d1f313c8f7a48acc3fe35abf7154c768fba8947370a8ba4ffa57dfd5

Contents?: true

Size: 957 Bytes

Versions: 33

Compression:

Stored size: 957 Bytes

Contents

# frozen_string_literal: true

require "active_support/concern"

module Decidim
  # Tells/Extends time before inactivity warning or automatic logout.
  class TimeoutsController < Decidim::ApplicationController
    include Decidim::SkipTimeoutable

    # Skip these methods because they can call Devise's store_location_for, which can save timeouts path to session.
    skip_before_action :store_current_location

    prepend_before_action :skip_timeout, only: :seconds_until_timeout

    def seconds_until_timeout
      time_remaining = current_user ? Decidim.config.expire_session_after - (Time.current - Time.zone.at(user_session["last_request_at"])) : 0
      respond_to do |format|
        format.json { render json: { seconds_remaining: time_remaining.to_i }, status: :ok }
      end
    end

    # If user wants to continue session after inactivity warning.
    def heartbeat
      respond_to do |format|
        format.js
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/controllers/decidim/timeouts_controller.rb
decidim-core-0.28.4 app/controllers/decidim/timeouts_controller.rb
decidim-core-0.27.9 app/controllers/decidim/timeouts_controller.rb
decidim-core-0.29.0 app/controllers/decidim/timeouts_controller.rb
decidim-core-0.28.3 app/controllers/decidim/timeouts_controller.rb
decidim-core-0.27.8 app/controllers/decidim/timeouts_controller.rb
decidim-core-0.29.0.rc4 app/controllers/decidim/timeouts_controller.rb
decidim-core-0.29.0.rc3 app/controllers/decidim/timeouts_controller.rb
decidim-core-0.29.0.rc2 app/controllers/decidim/timeouts_controller.rb
decidim-core-0.29.0.rc1 app/controllers/decidim/timeouts_controller.rb
decidim-core-0.28.2 app/controllers/decidim/timeouts_controller.rb
decidim-core-0.27.7 app/controllers/decidim/timeouts_controller.rb
decidim-core-0.28.1 app/controllers/decidim/timeouts_controller.rb
decidim-core-0.27.6 app/controllers/decidim/timeouts_controller.rb
decidim-core-0.26.10 app/controllers/decidim/timeouts_controller.rb
decidim-core-0.26.9 app/controllers/decidim/timeouts_controller.rb
decidim-core-0.28.0 app/controllers/decidim/timeouts_controller.rb
decidim-core-0.27.5 app/controllers/decidim/timeouts_controller.rb
decidim-core-0.28.0.rc5 app/controllers/decidim/timeouts_controller.rb
decidim-core-0.28.0.rc4 app/controllers/decidim/timeouts_controller.rb