Sha256: 30f4279fc3e83b888d15e12bdd004975eab3e06add0d506bde1a1b80abb739f0

Contents?: true

Size: 1.2 KB

Versions: 8

Compression:

Stored size: 1.2 KB

Contents

module Ixtlan
  module Guard
    class AbstractSession

      attr_accessor :permissions, :user, :idle_session_timeout

      def self.create(login, password)
        self.do_create(authenticate(login, password))
      end
      
      def self.create_remote(login, password)
        self.do_create(authenticate_remote(login, password))
      end
      
      private

      def self.do_create(user)
        result = new
        
        if user.valid?
          result.user = user
        else
          result.log = user.to_log # error message
        end
        result
      end

      public

      def log=(msg)
        @log = msg
      end

      def to_log
        if @log
          @log
        else
          "Session(user-id: #{user.id}, idle-session-timeout: #{idle_session_timeout})"
        end
      end

      def valid?
        @log.nil?
      end
      
      def attributes
        {'idle_session_timeout' => idle_session_timeout, 'permissions' => permissions, 'user' => user}
      end
      
      protected

      def self.authenticate(login, password)
        raise "not implemented"
      end

      def self.authenticate_remote(login, password)
        raise "not implemented"
      end
    end
  end
end  

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ixtlan-guard-0.9.0 lib/ixtlan/guard/abstract_session.rb
ixtlan-guard-0.8.3 lib/ixtlan/guard/abstract_session.rb
ixtlan-guard-0.8.2 lib/ixtlan/guard/abstract_session.rb
ixtlan-guard-0.8.1 lib/ixtlan/guard/abstract_session.rb
ixtlan-guard-0.8.0 lib/ixtlan/guard/abstract_session.rb
ixtlan-guard-0.7.2 lib/ixtlan/guard/abstract_session.rb
ixtlan-guard-0.7.0 lib/ixtlan/guard/abstract_session.rb
ixtlan-guard-0.6.1 lib/ixtlan/guard/abstract_session.rb