Sha256: f3460a138548b51a5b5d1e769dea2b3fd99f7b0b07509fee67cedc9005a65e00

Contents?: true

Size: 1014 Bytes

Versions: 11

Compression:

Stored size: 1014 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
    # 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

    private

    def skip_timeout
      request.env["devise.skip_timeoutable"] = true
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
decidim-core-0.26.1 app/controllers/decidim/timeouts_controller.rb
decidim-core-0.26.0 app/controllers/decidim/timeouts_controller.rb
decidim-core-0.26.0.rc2 app/controllers/decidim/timeouts_controller.rb
decidim-core-0.26.0.rc1 app/controllers/decidim/timeouts_controller.rb
decidim-core-0.25.2 app/controllers/decidim/timeouts_controller.rb
decidim-core-0.25.1 app/controllers/decidim/timeouts_controller.rb
decidim-core-0.25.0 app/controllers/decidim/timeouts_controller.rb
decidim-core-0.25.0.rc4 app/controllers/decidim/timeouts_controller.rb
decidim-core-0.25.0.rc3 app/controllers/decidim/timeouts_controller.rb
decidim-core-0.25.0.rc2 app/controllers/decidim/timeouts_controller.rb
decidim-core-0.25.0.rc1 app/controllers/decidim/timeouts_controller.rb