Sha256: d0e8b5bd024027d838d65f5535bbbca205d7e9e3e290bc91bc2aa56c5dfbe091

Contents?: true

Size: 884 Bytes

Versions: 3

Compression:

Stored size: 884 Bytes

Contents

module Kaui
  # Subclassed to specify the correct layout
  class SessionsController < Devise::SessionsController

    layout Kaui.config[:layout]

    skip_before_action :check_for_redirect_to_tenant_screen, raise: false

    protected

    # Override after_sign_in_path_for to not have to rely on the default 'root' config which we want to keep on home#index
    def after_sign_in_path_for(resource)
      # Clear the tenant_id from the cookie to not rely on old cookie data
      session[:kb_tenant_id] = nil
      stored_location_for(:user) || Kaui.tenant_home_path.call
    end

    def after_sign_out_path_for(resource)
      kaui_path
    end

    def require_no_authentication
      super
      # Remove the somewhat confusing message "You are already signed in."
      flash.discard(:alert) if flash[:alert] == I18n.t("devise.failure.already_authenticated")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kaui-2.1.0 app/controllers/kaui/sessions_controller.rb
kaui-2.0.4 app/controllers/kaui/sessions_controller.rb
kaui-2.0.3 app/controllers/kaui/sessions_controller.rb