Sha256: 20601a3afb6a2bdd884a06581c526b5f1e04fc80f373f580480527b7f71a8f9d

Contents?: true

Size: 610 Bytes

Versions: 2

Compression:

Stored size: 610 Bytes

Contents

require 'rubycas/server/activerecord/model/ticket'
require 'rubycas/server/activerecord/model/consumable'

module RubyCAS::Server::Core::Tickets
  class LoginTicket < ActiveRecord::Base
    include RubyCAS::Server::Core::Ticket
    #include RubyCAS::Server::Core::Consumable


    validates :ticket, :client_hostname, presence: true

    def expired?(max_lifetime)
      lifetime = Time.now.to_i - created_at.to_time.to_i
      lifetime > max_lifetime
    end

    def consumed?
      consumed.nil? ? false : true
    end

    def consume!
      self.consumed = Time.zone.now
      self.save
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubycas-server-activerecord-0.0.3 lib/rubycas/server/activerecord/model/login_ticket.rb
rubycas-server-activerecord-0.0.2 lib/rubycas/server/activerecord/model/login_ticket.rb