Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Andrew <mail@timothyandrew.net>2016-04-19 12:58:35 +0300
committerTimothy Andrew <mail@timothyandrew.net>2016-04-28 19:58:36 +0300
commitfb2da6795c8503db5fed0f856760289e87ea9419 (patch)
tree7023b093ee4b803d4bd328eb66d82a0514a6d923 /app/models/personal_access_token.rb
parent41b4e119e9b076cc0f36bd31cbb42f87e5ecb08f (diff)
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.rb3
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)