Sha256: 9bb21a5fa26257d12fc6e2b23dd5a17fe4879c16ddf23e9c301206fc4a1dc32a

Contents?: true

Size: 1.24 KB

Versions: 10

Compression:

Stored size: 1.24 KB

Contents

module Renalware
  class Devise::SessionsController < ::Devise::SessionsController
    include Concerns::DeviseControllerMethods

    layout "renalware/layouts/application"

    # Define the path to go to after logging in:
    # - if the user has never before logged-in, devise will take them to the root path (dashboard)
    # - if the user's session timed-out less that 30 minutes ago, we take them back to the
    #    last page they were on.
    # - if the user's session timed-out more than 30 minutes ago, we take them back to the
    #    their dashboard. See PR #1592 for rationale.
    # - if the user has explicitly logged-out they will always go the the dashboard path on login,
    #   regardless of how long ago they signed out, because in this instance devise removes it's
    #   entries in the session cookie.
    def after_sign_in_path_for(resource)
      max_duration_of_url_memory = Renalware.config.duration_of_last_url_memory_after_session_expiry
      max_duration_has_passed = last_sign_in_at <= max_duration_of_url_memory.ago
      max_duration_has_passed ? dashboard_path : super
    end

    private

    def last_sign_in_at
      current_user.last_sign_in_at || epoch_start
    end

    def epoch_start
      Date.new(0)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.rc3 app/controllers/renalware/devise/sessions_controller.rb
renalware-core-2.0.0.pre.rc1 app/controllers/renalware/devise/sessions_controller.rb
renalware-core-2.0.0.pre.beta12 app/controllers/renalware/devise/sessions_controller.rb
renalware-core-2.0.0.pre.beta11 app/controllers/renalware/devise/sessions_controller.rb
renalware-core-2.0.0.pre.beta10 app/controllers/renalware/devise/sessions_controller.rb
renalware-core-2.0.0.pre.beta9 app/controllers/renalware/devise/sessions_controller.rb
renalware-core-2.0.0.pre.beta8 app/controllers/renalware/devise/sessions_controller.rb
renalware-core-2.0.0.pre.beta7 app/controllers/renalware/devise/sessions_controller.rb
renalware-core-2.0.0.pre.beta6 app/controllers/renalware/devise/sessions_controller.rb
renalware-core-2.0.0.pre.beta5 app/controllers/renalware/devise/sessions_controller.rb