diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2016-04-19 15:28:35 +0530 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2016-04-28 22:28:36 +0530 |
commit | fb2da6795c8503db5fed0f856760289e87ea9419 (patch) | |
tree | 7023b093ee4b803d4bd328eb66d82a0514a6d923 /app/models/personal_access_token.rb | |
parent | 41b4e119e9b076cc0f36bd31cbb42f87e5ecb08f (diff) | |
download | gitlab-ce-fb2da6795c8503db5fed0f856760289e87ea9419.tar.gz |
Add an "Inactive Personal Access Tokens" section.
- Show the count for each section in parens
- Remove the `revoked?` check, because everything in the
active section is guaranteed to not be revoked.
Diffstat (limited to 'app/models/personal_access_token.rb')
-rw-r--r-- | app/models/personal_access_token.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/app/models/personal_access_token.rb b/app/models/personal_access_token.rb index dd64374481f..fff3f76fb93 100644 --- a/app/models/personal_access_token.rb +++ b/app/models/personal_access_token.rb @@ -1,7 +1,8 @@ class PersonalAccessToken < ActiveRecord::Base belongs_to :user - scope :active, -> { where.not(revoked: true).where("expires_at >= :current", current: Time.current) } + 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) |