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:
authorTiago Botelho <tiagonbotelho@hotmail.com>2017-02-27 21:56:54 +0300
committerTiago Botelho <tiagonbotelho@hotmail.com>2017-03-01 16:11:11 +0300
commit2b474dc2b226460782413e634792cf83e791173b (patch)
treeaa4520aae3d0a1130a3349699a2e0c20f344aa39 /app/models/personal_access_token.rb
parent9f2e4742e354f5548b4956060f1bfa5ee3bd6657 (diff)
refactors finder and correlated code
Diffstat (limited to 'app/models/personal_access_token.rb')
-rw-r--r--app/models/personal_access_token.rb7
1 files changed, 3 insertions, 4 deletions
diff --git a/app/models/personal_access_token.rb b/app/models/personal_access_token.rb
index 676e0832d54..22809fe1487 100644
--- a/app/models/personal_access_token.rb
+++ b/app/models/personal_access_token.rb
@@ -9,11 +9,10 @@ class PersonalAccessToken < ActiveRecord::Base
before_save :ensure_token
- default_scope { where(impersonation: false) }
- scope :active, -> { where(revoked: false).where("expires_at >= NOW() OR expires_at IS NULL") }
+ scope :active, -> { where("revoked = false AND (expires_at >= NOW() OR expires_at IS NULL)") }
scope :inactive, -> { where("revoked = true OR expires_at < NOW()") }
- scope :impersonation, -> { unscoped.where(impersonation: true) }
- scope :with_impersonation_tokens, -> { unscoped }
+ scope :with_impersonation, -> { where(impersonation: true) }
+ scope :without_impersonation, -> { where(impersonation: false) }
def revoke!
self.revoked = true