Sha256: 6c4f9224b41a0e2741cfcf97d17437a45a3b2c8efb1be90d7332b32eb4a08f76

Contents?: true

Size: 396 Bytes

Versions: 49

Compression:

Stored size: 396 Bytes

Contents

module Adeia
  class Token < ActiveRecord::Base
    belongs_to :permission, foreign_key: :adeia_permission_id

    validates :permission, presence: true
    validates :exp_at, presence: true

    before_create :generate_token

    def is_valid?
      exp_at > Time.now && is_valid
    end

    private

    def generate_token
      self.token = SecureRandom.urlsafe_base64
    end
    
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
adeia-0.11.0 app/models/adeia/token.rb
adeia-0.10.5 app/models/adeia/token.rb
adeia-0.10.4 app/models/adeia/token.rb
adeia-0.10.3 app/models/adeia/token.rb
adeia-0.10.2 app/models/adeia/token.rb
adeia-0.10.1 app/models/adeia/token.rb
adeia-0.10.0 app/models/adeia/token.rb
adeia-0.9.2 app/models/adeia/token.rb
adeia-0.9.1 app/models/adeia/token.rb
adeia-0.9.0 app/models/adeia/token.rb
adeia-0.8.6 app/models/adeia/token.rb
adeia-0.8.5 app/models/adeia/token.rb
adeia-0.8.4 app/models/adeia/token.rb
adeia-0.8.3 app/models/adeia/token.rb
adeia-0.8.2 app/models/adeia/token.rb
adeia-0.8.1 app/models/adeia/token.rb
adeia-0.8.0 app/models/adeia/token.rb
adeia-0.7.1 app/models/adeia/token.rb
adeia-0.7.0 app/models/adeia/token.rb
adeia-0.6.2 app/models/adeia/token.rb