Sha256: 941a1a8d39f0b0ea89c500cadafe13530dca4441fa5035a94ab8b0310591c631
Contents?: true
Size: 742 Bytes
Versions: 5
Compression:
Stored size: 742 Bytes
Contents
require 'active_support/concern' module TokenAuthenticateMe module Models module Sessionable extend ActiveSupport::Concern included do before_create :generate_unique_key def attributes { 'key' => key, 'expiration' => expiration, 'created_at' => created_at, 'updated_at' => updated_at } end private def generate_unique_key begin self.key = SecureRandom.hex end while self.class.exists?(key: key) # rubocop:disable Lint/Loop self.expiration = expiration_hours.hours.from_now end def expiration_hours 24 end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems