evodata/app/models/api_key.rb

16 lines
317 B
Ruby
Raw Normal View History

class ApiKey < ApplicationRecord
encrypts :token, deterministic: true
belongs_to :bearer, polymorphic: true
def self.authenticate_by_token!(token)
find_by! token: token
end
def self.authenticate_by_token(token)
authenticate_by_token! token
rescue ActiveRecord::RecordNotFound
nil
end
2023-02-26 15:09:08 +01:00
end