Sha256: de44ef094099c1b0fbab507d6fcac9aaaa77db4cbe2df1c86eeef997269c4393
Contents?: true
Size: 521 Bytes
Versions: 2
Compression:
Stored size: 521 Bytes
Contents
class ApiKey < ActiveRecord::Base belongs_to :token_authenticatable, polymorphic: true before_create :generate_access_token, :set_expiry_date def expired? expired_at < Time.now.utc end def renew! generate_access_token set_expiry_date save! end private def set_expiry_date self.expired_at = SimpleTokenAuth.expire_in.since end def generate_access_token begin self.access_token = SecureRandom.hex end while self.class.exists?(access_token: access_token) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
simple_token_auth-0.0.4 | test/dummy/app/models/api_key.rb |
simple_token_auth-0.0.3 | test/dummy/app/models/api_key.rb |