Sha256: 0e7bc6a95daf061e381cfcb70eaf1998fd02e17260cd1e570929f76dbc262e14

Contents?: true

Size: 725 Bytes

Versions: 20

Compression:

Stored size: 725 Bytes

Contents

module Spina
  module Authentication
    module Sessions
      extend ActiveSupport::Concern
      
      included do
        helper_method :current_spina_user
        helper_method :logged_in?
        helper_method :logout_path
      end
      
      def current_spina_user
        Spina::Current.user ||= User.find_by(id: session[:spina_user_id]) if session[:spina_user_id]
      end
      
      def logged_in?
        current_spina_user
      end
      
      def logout_path
        spina.admin_logout_path
      end
      
      private
      
        def authenticate
          redirect_to admin_login_path, flash: {information: I18n.t('spina.notifications.login')} unless logged_in?
        end
    
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
spina-2.12.0 lib/spina/authentication/sessions.rb
spina-2.11.0 lib/spina/authentication/sessions.rb
spina-2.10.0 lib/spina/authentication/sessions.rb
spina-2.9.1 lib/spina/authentication/sessions.rb
spina-2.9.0 lib/spina/authentication/sessions.rb
spina-2.8.1 lib/spina/authentication/sessions.rb
spina-2.8.0 lib/spina/authentication/sessions.rb
spina-2.7.0 lib/spina/authentication/sessions.rb
spina-2.6.2 lib/spina/authentication/sessions.rb
spina-2.6.1 lib/spina/authentication/sessions.rb
spina-2.6.0 lib/spina/authentication/sessions.rb
spina-2.5.0 lib/spina/authentication/sessions.rb
spina-2.4.0 lib/spina/authentication/sessions.rb
spina-2.3.5 lib/spina/authentication/sessions.rb
spina-2.3.4 lib/spina/authentication/sessions.rb
spina-2.3.3 lib/spina/authentication/sessions.rb
spina-2.3.2 lib/spina/authentication/sessions.rb
spina-2.3.1 lib/spina/authentication/sessions.rb
spina-2.3.0 lib/spina/authentication/sessions.rb
spina-2.2.0 lib/spina/authentication/sessions.rb