fb2da6795c
- Show the count for each section in parens - Remove the `revoked?` check, because everything in the active section is guaranteed to not be revoked.
17 lines
517 B
Ruby
17 lines
517 B
Ruby
class PersonalAccessToken < ActiveRecord::Base
|
|
belongs_to :user
|
|
|
|
scope :active, -> { where(revoked: false).where("expires_at >= :current OR expires_at IS NULL", current: Time.current) }
|
|
scope :inactive, -> { where("revoked = true OR expires_at < :current", current: Time.current) }
|
|
|
|
def self.generate(params)
|
|
personal_access_token = self.new(params)
|
|
personal_access_token.token = Devise.friendly_token(50)
|
|
personal_access_token
|
|
end
|
|
|
|
def revoke!
|
|
self.revoked = true
|
|
self.save
|
|
end
|
|
end
|